本文介绍了在sql查询中给出两个条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的情况下
i有个人喜欢的表格
in my case
i have a table personal like
name book
josh bk101
alen bk101
josh bk102
还有另外一张表好像
also another table fine like
name book
josh bk101
alen bk101
i必须检查是否记录在罚款表中。必须检查这两种情况。
i have to check whether the record in fine table.at a time i have to check both cases.
推荐答案
select a.*, case when b.name is null then 'yes' else 'no' end as IsExistInFineTbl
from Personal as a
Left join fine as b on a.name=b.name and a.book=b.book
结果......
result...
name book IsExistInFineTbl
-----------------------------------------------
josh bk101 yes
alen bk101 yes
josh bk102 no
快乐编码!
:)
Happy Coding!
:)
这篇关于在sql查询中给出两个条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!