gpt4 book ai didi

mysql - 我可以执行 `select * from table where id in ()

转载 作者:行者123 更新时间:2023-11-30 00:14:39 24 4
gpt4 key购买 nike

假设我想在 mysql 中执行以下查询:

select id from tbl where id in (2,3)

但是字符串“2,3”已经存储在另一个表的列中,例如tbl2.data。是否可以做类似以下的事情:

select id from tbl where id in (select data from tbl2 where x=y);

当我尝试时,结果等于

select id from tbl where id in (2);

就好像结果被转换为第一个数字

最佳答案

尝试一下:

    (select group_concat(data) from tbl2 where x=y);

或者简单地使用这个。

   select id from tbl 
INNER JOIN tbl2
ON tbl.id = tbl2.data
WHERE x=Y

关于mysql - 我可以执行 `select * from table where id in (<string from another query>),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23761995/

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