Is it possible to select multiple values from a subquery in SELECT block?
是否可以从select块中的子查询中选择多个值?
Selecting one value works fine like this:
选择一个值可以这样工作:
SELECT
a.id,
(SELECT b.id FROM b WHERE b.a_id = a.id) AS b_id
FROM
a
But if i also want to get the b.name and i change the query to this:
但是如果我也想要得到b。name并将查询改为:
SELECT
a.id,
(SELECT b.id, b.name FROM b WHERE b.a_id = a.id)
FROM
a
... it doesn't work anymore. One possibility would be to put the subquery to FROM block and take values from there but in my particular query that doesn't work so i would like to solve in SELECT block. Thank you!
…它不工作了。一种可能是将子查询放到block中并从那里获取值,但是在我的特定查询中,它不能工作,所以我想在SELECT block中解决这个问题。谢谢你!
1 个解决方案
#1
2
This will help you
这将帮助你
SELECT A.ID,
B.ID,
B.NAME
FROM A INNER JOIN B ON B.A_ID=A.ID;
#1
2
This will help you
这将帮助你
SELECT A.ID,
B.ID,
B.NAME
FROM A INNER JOIN B ON B.A_ID=A.ID;