Answer the question
In order to leave comments, you need to log in
Temporary table in MySQL inside SELECT
There is a one-dimensional array of the form: key => value
A MySQL query is being executed: select `key`, `field` from `table` where `key` in (key1, key2, key3)
Then we run through the result:
result += array[key]*field
As a result, the desired number is in the “result” variable
Question:
Is it possible to somehow limit ourselves to one mysql query so that it already contains “result”, something like:
select sum(`table`.`field`*`temp`.`value`) from `table`, (key1 => value1, key2 => value2, key3 => value3) as `temp` where `key` in (key1, key2, key3) and `table`.`key`=`temp`.`key`
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question