Mysql 什么';将多个ID选择到一个变量中,然后在in中使用该ID的语法
我不知道该怎么做下面的。。。我很确定这是可能的,但我得到了糟糕的语法错误Mysql 什么';将多个ID选择到一个变量中,然后在in中使用该ID的语法,mysql,Mysql,我不知道该怎么做下面的。。。我很确定这是可能的,但我得到了糟糕的语法错误 /*pseudo*/ set @ids = select id from table_a limit 1,10; select * from table_b where table_a_id in (@ids); 我只想将select放在in()中,但mySQL表示它不愿意在有限制的in中进行子select 提前感谢您可以这样做: select * from table_b where table_a_id in (s
/*pseudo*/
set @ids = select id from table_a limit 1,10;
select * from table_b where table_a_id in (@ids);
我只想将select放在in()中,但mySQL表示它不愿意在有限制的in中进行子select
提前感谢您可以这样做:
select * from table_b where table_a_id in (select id from @ids);
select table_b.*
from table_b
join (select id from table_a limit 1,10) As table_a
on table_b.table_a_id = table_a.id
您应该能够通过连接派生表来实现这一点
SELECT
table_b.id,
table_b.otherfield
FROM table_b
JOIN (SELECT id FROM table_a LIMIT 1,10) a_limit ON table_b.table_a_id = a_limit.id
我猜你是说第三排的“a桌”?