gpt4 book ai didi

mysql - 从哪个表中检索数据

转载 作者:太空宇宙 更新时间:2023-11-03 10:51:40 27 4
gpt4 key购买 nike

SELECT username,
password,
FROM table1
WHERE username = :username
UNION ALL
SELECT username,
password,
FROM table2
WHERE username = :username

我想查找从哪个表中检索到的数据,无论是从表 1 还是从表 2而且这些表中插入的数据是唯一的

提前致谢

最佳答案

添加包含此信息的列:

SELECT 'table1' as which, username, password
FROM table1
WHERE username = :username
UNION ALL
SELECT 'table2' as which, username, password
FROM table2
WHERE username = :username;

关于mysql - 从哪个表中检索数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24429109/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com