I want to execute a SQL query in mysql something like the below:
SELECT
(0-5) AS `sqlTest`, if(`sqlTest` < 0, 'false', 'true')
But I am getting an error "Unknown column 'sqlTest' in 'field list'"
This is not an exact query. Here the operands 0 and 5 will be replaced with 2 big Select queries.
Hey i got the answer of your question. here,
try this,
SELECT @var:=(0-5) AS sqlTest, if(@var< 0, 'false', 'true');
Since you're using MySQL, you can use a temporary to solve it;
SELECT @tmp := (0-5) AS `sqlTest`, if(@tmp < 0, 'false', 'true')
Simple demo here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With