如何用SQL语句比较两个表中字段的差异,并将其列出来
在线等

解决方案 »

  1.   

    如果是把两个表中字段不相同的列出来,可以这样
    select a.col2,b.col2
    from a,b
    where a.col1=b.col1 and a.col2<>b.col2
      

  2.   

    如果是把两个表中不相同的字段名称列出来,可以这样SELECT table_name,column_name FROM information_schema.`COLUMNS` where table_schema='数据库名' and find_in_set(table_name,'表A,表B') group by column_name having count(1)=1;其他属性的差异可以看information_schema.`COLUMNS`自行扩展。