我有一个项目表,其中存储了所有项目和项目建议的列表。如果建议被接受,那么它们也会成为项目。
id p_name suggestion accepted
1 abc 0 pending
2 fgh 1 pending
3 aec 1 yes
4 etc 1 pending
现在我想要一个只显示以下行的查询。
id p_name suggestion accepted
1 abc 0 pending
2 aec 1 yes
是这样的
select * from table if('suggestion'== 1)then get only where('accepted','yes') otherwise get only those rows which have suggestion == 0
最佳答案
这个?
select
*
from
"table" t
where
t.suggestion = 0
or
( t.suggestion = 1 and t.accepted = 'yes' )
关于mysql - 如何在 mysql 中使用带有 if else 条件的 Where 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46110218/