L
L
leha782015-11-11 07:27:35
PHP
leha78, 2015-11-11 07:27:35

How to correctly compose a condition in MYSQL (example inside)?

I need to output data by comparing 2 cells in the same table. For example price and old_price, output if price is less than old_price

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Dyrkov, 2015-11-11
@leha78

SELECT price, old_price FROM table WHERE price < old_price

T
Talgat Baltasov, 2015-11-11
@talgatbaltasov

select case 
when price < old_price then price 
when old_price < price then old_price 
end as final_price

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question