说我想在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);


或简单地使用this。

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

关于mysql - 我可以从表中的id(<<另一个查询的字符串>)中执行`select *,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23761995/

10-12 12:54
查看更多