简体   繁体   中英

MySQL IF ELSE true false

SELECT IF(price == null, 0, price) FROM trips 
WHERE id=9 and prices LIKE "%|s|1|%" and prices LIKE "%|ss|24|%"

If LIKE "%|ss|2|% " do that price if there is a LIKE "%|ss|24|%" doing nothing shows you have to make it 0 .

Nothing is showing up because there is no prices value containing "|s|1|" and "|ss|24|". I think you should use an OR instead.

SELECT IF(price == null, 0, price) FROM trips 
WHERE id=9 and (prices LIKE "%|s|1|%" OR prices LIKE "%|ss|24|%");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM