Reputation: 1967
Is it possible to select multiple values from a subquery in SELECT block?
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:
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!
Upvotes: 1
Views: 1460
Reputation: 11375
This will help you
SELECT A.ID,
B.ID,
B.NAME
FROM A INNER JOIN B ON B.A_ID=A.ID;
Upvotes: 2