sql中怎么两个表,怎么把一个表查出来的数据,追加显示到另一个表的右边。两个表的数据量一样
如图:select*fromIngoods_detailsselectasag.afrom(selectCASEwhenIngoods_details.Ingoods_I...
如图:select * from Ingoods_detailsselect asag.a from (select CASE when Ingoods_details.Ingoods_IsPay=4 then 4 else null end a ,Ingoods_details.*from Ingoods_details join Stockist_inStock on Ingoods_details.Stockist_inStockid=Stockist_inStock.Stockist_inStockid where SupplierInfo_id=1 ) as asag
select * from Ingoods_details
select asag.a from (select
CASE when Ingoods_details.Ingoods_IsPay=4
then 4 else null end a ,Ingoods_details.*
from Ingoods_details join Stockist_inStock on Ingoods_details.Stockist_inStockid=Stockist_inStock.Stockist_inStockid
where SupplierInfo_id=1 ) as asag 展开
select * from Ingoods_details
select asag.a from (select
CASE when Ingoods_details.Ingoods_IsPay=4
then 4 else null end a ,Ingoods_details.*
from Ingoods_details join Stockist_inStock on Ingoods_details.Stockist_inStockid=Stockist_inStock.Stockist_inStockid
where SupplierInfo_id=1 ) as asag 展开
2017-08-18
展开全部
sql中怎么两个表,怎么把一个表查出来的数据,追加显示到另一个表的右边。两个表的数据量一样
连接后查询没有对应的数据很简单,假设你有一张产品表,还有一张销售表,而你想关联后找到哪些产品没有销售,代码如下:
select * from 产品表 a
left join 销售表 b on a.产品ID=b.产品ID
where b.产品ID is null
这样写就可以查找出产品表没有在销售表出现的数据。
顺便给楼主介绍一下几种关联:
join 左表(主表)和右表(子表)都存在的数据
left join 左表(主表)为查找全集,右表(子表)存在的关联出来,不存在的为NULL。
right join 刚好和left join相反
full join 相当于把left join 和right join 综合起来,即左表(主表)和右表(子表)关联,如果能关联到的显示,如果左有右表没有,则右表显示NULL,如果右表有左表没有 则左表显示NULL
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询