Mysql order on calculation with variable from outside tables

46
February 12, 2019, at 10:30 AM

Can I do a calculation like this in MySQL:

somefield * (someotherfield * somethirdfield - MYVALUE)

where MYVALUE would be filled in to the query using my client?

Answer 1

You need to use parameterized query. Pass MYVALUE as input/parameter.

This might help.

Answer 2

parameterized (named) queries has @ prefix, thus

somefield * (someotherfield * somethirdfield - @myVal)

if you are using ODBC client, then you need to use ? since ODBC client does not support named parameters.

somefield * (someotherfield * somethirdfield - ?)

Depending on the client which you are using you need to formulate the rest. You can check parameterized queries

READ ALSO
What type of join to use here?

What type of join to use here?

I have two tables: StorageTransactions and FutureStockUsageMaterials

62
How to check if directory is correct for uploading files in php?

How to check if directory is correct for uploading files in php?

I am making an application form for users to apply for jobs and upload their CVsThe php code I made sends the file name to the DB so it is working correctly I guess

59
Creating a Pivot (crosstab) query for a golf league [on hold]

Creating a Pivot (crosstab) query for a golf league [on hold]

I’m trying to create a pivot query (Cross Tab)for a golf league with about 20 playersIn my database I place the playerID, Name, Date, Round#(1,2,3, etc) and score

49
Access denied for user root@localhost on Ubuntu and OS X

Access denied for user root@localhost on Ubuntu and OS X

I'm developing a web application and it is working just fine in Windows, but now I'm trying to run it in Ubuntu and in a Macbook and it's giving me a Access denied error

43