gpt4 book ai didi

MySQL 检查同一查询中两个表中是否存在值

转载 作者:行者123 更新时间:2023-11-29 08:17:52 25 4
gpt4 key购买 nike

如何编写一个查询(如果可能)来同时在两个表中搜索数据/信息?

表1表2中搜索“值”,其中参数

最佳答案

您可以使用UNION来做到这一点(如果您想保留重复的结果,请使用UNION ALL)。

例如:

select col1,col2 from table1 where col1 = 1
union
select col1,col2 from table2 where col1 = 1

关于MySQL 检查同一查询中两个表中是否存在值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20198970/

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