如果我在MySQL数据库中有两个表都有一个名为order_number
的列,给定order_number
值但不知道它来自哪个表我将如何设置查询会返回找到的表的名称吗?
我对表的名称特别感兴趣,所以我可以设置该表的后续更新。
另外,我使用PHP来处理查询。
答案 0 :(得分:2)
select "tableA" as tableName,order_number from tableA where order_number=5
UNION
select "tableB" as tableName,order_number from tableB where order_number=5;