我有两张桌子
如何选择具有optionName =' email'和值= 1或者选项表中没有电子邮件条目?
答案 0 :(得分:2)
试试这个:
select * from User u inner join Option o on u.id = o.userid
where (o.optionName = 'email' and o.value = 1) or (o.optionName <> 'email')
答案 1 :(得分:0)
这可能会对你有所帮助:
"SELECT * from users u left join options o on u.id = o.userid where (o.optionName = 'email' and o.value = 1) or o.userid is null; ";