首页 新闻 会员 周边

怎么查询2个表

0
[待解决问题]

有2个表,结构一样的,都有一个列 match,2个表 match列的值有相同的,我想查询2个表所有distinct出来的match和对应match的个数,菜鸟就高手解救

Sureboy的主页 Sureboy | 菜鸟二级 | 园豆:212
提问于:2012-11-09 17:39
< >
分享
所有回答(2)
0

select distinct match from (

select * from 表1 union all select * from 表2

select count(1) from (

select distinct match from (

select * from 表1 union all select * from 表2

select * from 表1 union all select * from 表2

)

jingjunfeng | 园豆:873 (小虾三级) | 2012-11-09 18:02
0

select match  from(select match from 表1 union select match from 表2)

union all

select count(1) as match from (select match from 表1 union select match from 表2)

union联合两张表会消除重复数据。

leroylei | 园豆:228 (菜鸟二级) | 2012-11-10 01:48
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册