简单的联合查询,只要写对,立马给分。在线,要分的速度。解决思路

简单的联合查询,只要写对,立马给分。在线,要分的速度。

大家帮忙来个两表联合查询:

表A

sheng       shi

吉林         长春

吉林         四平

吉林         白城

辽宁         鞍山

辽宁         四平

表B

sheng       shi

吉林         长春

吉林         长春

吉林         长春

吉林         四平

吉林         四平

表A里面没有重复的记录,表B里面有重复的,我想找出的结果为:

sheng       shi

吉林         白城

辽宁         鞍山

辽宁         四平

假如吉林和辽宁都有四平这个市,

该怎么联合查询呢?大家帮忙下,弄了很久就是不好使。

只要好使立马给分



你要是市好像没什么规律啊




select * from chengshi

where id not in (

select a.id from chengshi a,chengshi_bak b

where a.sheng = b.sheng and a.shi = b.shi

group by a.id)


try this:

select * from tabA

where sheng+ ‘_ ‘+shi not in

(

select sheng+ ‘_ ‘+shi from tabB

group by sheng, shi

)

简单的联合查询,只要写对,立马给分。在线,要分的速度。解决思路

相关文章:

你感兴趣的文章:

标签云: