检索匹配 4 个表中任意 2 个表中的字段的记录
Retrieve records on matching a field in any 2 tables out of 4 tables
我有四个具有相同字段的表。现在我想以这样的方式连接这些表,即仅当字段(如名称)上的任何 two 表之间存在匹配时才检索记录。
提前致谢。
这将 return 出现在多个 table:
中的所有 name
值
select
name
from
(select distinct
name
from table1
union all
select distinct
name
from table2
union all
select distinct
name
from table3
union all
select distinct
name
from table4) temp
group by name
having count(*) > 1;
我有四个具有相同字段的表。现在我想以这样的方式连接这些表,即仅当字段(如名称)上的任何 two 表之间存在匹配时才检索记录。 提前致谢。
这将 return 出现在多个 table:
中的所有name
值
select
name
from
(select distinct
name
from table1
union all
select distinct
name
from table2
union all
select distinct
name
from table3
union all
select distinct
name
from table4) temp
group by name
having count(*) > 1;