SQL查询语句看不懂阿?
一个数据库3个表格:
ktab客户信息表,主键khh客户号
stab商品信息表,主键sph商品号
kstab订货表,主键khh和sph,属性dhl订货量
查询没有订货的客户的个人信息:
select * from ktab
where not exists (select * from kstab where khh=ktab.khh)
go
查询所用客户都订购了的商品的商品信息:
select * from stab
where not exists (select * from ktab
where not exists (select * from kstab
where sph=stab.sph and khh=ktab.khh ))
go
上面的语句怎么理解呢?假如把它们转化成类C语言的算法描述,大概的嵌套和步骤是怎样的?我只有对具体的算法描述才能理解一些,SQL前面章节较简单的语句能理解,发现这一节不好理解,大脑无法思考。