2 simbleyou simbleyou 于 2017.09.05 14:32 提问

MSQL数据库查询语句问题

图片说明
如图所示,需要怎么写查询语句得到所有男性携带的物品

4个回答

qq_32763061
qq_32763061   2017.09.05 14:37
已采纳

Select a. wp from tb1_zb a, tb2_pop b where a. name =b. name and b. sex = '男' 应该是这样

m0_38093650
m0_38093650   2017.09.05 14:43

Select distinct a. wp from tb1_zb a, tb2_pop b where a. name =b. name and b. sex = '男'

需要加一个distinct,以防物品重复

Simor
Simor   2017.09.05 15:47

select a.name,a.wp from tb1_zb
left join tb2_pop as b on b.name = a.name
where b.sex='男'

WLY19930402
WLY19930402   2017.09.07 10:33

select wp

from tb1-zb

where name in

(select name
from tb2-pop

where sex='男')
或者
select wp

from tb1-zb a join tb2-pop b on a.name=b.name

where sex='男'

Csdn user default icon
上传中...
上传图片
插入图片