如何编写以下sql
select * from blogimage where blog_id = '1' and orientation = 'h'
但是...我想添加...
IF(and only if) orientation = 'h' is null... then use orientation = 'v'
最佳答案
如果您只想获取 1 条适用于偏好方向 = 'h' 的记录
SELECT * FROM blogimage
WHERE blog_id = '1' AND (orientation = 'h' OR orientation = 'v')
ORDER BY orientation ASC LIMIT 1
关于mysql - 如何在 mysql where 条件中编写正确的 IF CASE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21793388/