本文介绍了从哪个表中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SELECT username,
password,
FROM table1
WHERE username = :username
UNION ALL
SELECT username,
password,
FROM table2
WHERE username = :username
我想从哪个表中查找数据是从 table1 还是 table2 中检索到的而且这些表中插入的数据是唯一的
I want to find from which table the data as been retrieved whether from table1 or table2And ya the inserted data in these tables are unique
提前致谢
推荐答案
添加包含此信息的列:
SELECT 'table1' as which, username, password
FROM table1
WHERE username = :username
UNION ALL
SELECT 'table2' as which, username, password
FROM table2
WHERE username = :username;
这篇关于从哪个表中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!