我试图从一张桌子中找到他们在另一张桌子上没有相应记录的行。
<h1 id="header"> List King </h1>
<h2> Buy grocceries </h2>
<ul>
<li id="one" class="hot"> Fresh </li>
<li id="two" class="hot"> Fresh 1</li>
<li id="three" class="hot"> Fresh 2 </li>
<li id="one" class="cool"> Fresh </li>
<li id="two" class="cool"> Fresh 1</li>
<li id="three" class="cool"> Fresh 2 </li>
</ul>
问题是SQL不喜欢不匹配的列数。如何获取缺失的行和相关信息?
答案 0 :(得分:1)
select
* from data t1
where not exists(select 1 from applications a where a.cust_number=t1.cust_number)
;With cte
as
(
select cust_number from data
except
select cust_number applications
)
select * from data where cust_number in (select cust_number from cte)