MySQL IF ELSE true false

时间:2018-05-16 09:49:13

标签: mysql

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

如果LIKE "%|ss|2|%"如果有LIKE "%|ss|24|%"无所事事,请按照这个价格显示您必须0

1 个答案:

答案 0 :(得分:1)

没有任何内容显示,因为没有包含“| s | 1 |”的价格值和“| ss | 24 |”。我认为你应该使用OR。

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