有两个表
table1   table2
里面都是 品名、规格 两个字段我如何得到这两个表中所有的不重复的品名,规格数据?

解决方案 »

  1.   

    这样行不行:
    select a.*,b.* from a,b where b.品名 not in (select 品名 from a)
      

  2.   

    select distinct(品名),规格 from table1 union select * from table2
      

  3.   

    select a.品名,a.规格 from a union select b.品名,b.规格 from b where b.品名 not in (select 品名 from a)
      

  4.   

    select distinct(品名),规格 from table1 
    union 
    select distinct(table2 .品名),table2 .规格 from table2 where table2 . 品名 not in( select 品名  from table1 )
      

  5.   

    select 品名,规格 (select 品名,规格 from talbe1 union select 品名,规格 from talbe2) group by 品名,规格
      

  6.   

    select a.品名,a.规格 from (select 品名,规格 from talbe1 union select 品名,规格 from talbe2) a group by a.品名,a.规格
      

  7.   

    select distinct 品名 from (select distinct 品名 from table1 union select distinct 品名 from table2)
      

  8.   

    select distinct 品名 from (select distinct 品名 from table1 union select distinct 品名 from table2)