Display unmatched columns of two tables without a primary key

时间:2016-12-09 12:56:45

标签: mysql

I have two same tables residing in two different database libraries. Both the tables have around 150 columns. At any point of time there will be only one record/row in both the tables. I need to run a query which will return only the unmatched columns using SQL.

For Example: Table1

cmp env cust area  name.. ... ... ... 
ABC SUN XXXX EARTH xyz

Table2

cmp env cust area   name.. ... ... ... 
ABC MOON XXXX EARTH uvw

Can I get a result like this:

       env  name .. .. ... 
Table1 SUN  xyz 
Table2 MOON uvw

Thank you!!

1 个答案:

答案 0 :(得分:0)

答案是:不,不能仅在结果集中列出不匹配的列。原因是您需要在选择列表中包含所有列,以便运行查询。您可以使用各种过滤器从输出中排除记录,但不能从字段中排除。

显然,在应用程序中,您可以在用户界面中隐藏那些您知道字段值匹配的列,因为那时您已经知道底层数据是什么。