SELECT username,
password,
FROM table1
WHERE username = :username
UNION ALL
SELECT username,
password,
FROM table2
WHERE username = :username
我想从table1或table2中找到从哪个表中检索的数据 而且,这些表中插入的数据是唯一的
提前致谢
答案 0 :(得分:4)
添加包含以下信息的列:
SELECT 'table1' as which, username, password
FROM table1
WHERE username = :username
UNION ALL
SELECT 'table2' as which, username, password
FROM table2
WHERE username = :username;