Reputation: 5086
I am trying to write a query in the form of:
SELECT
field_a.table AS x,
field_b.table AS y,
( SELECT
field_a.tableb AS a,
field_b.tableb AS b,
FROM tableb) FROM table
However, I get the following error message: Operand should contain 1 column(s)
Is there any way this can be done or will I have to resort to multiple sub-queries? I just see it as quite inefficient.
Cheers
Upvotes: 0
Views: 159
Reputation: 180093
For your proposed query to make any sense at all, it must be the case that table tableb
has only one row. In that case, you can probably achieve your objective with a join instead of a subquery. Maybe this is what you want:
SELECT
table.field_a AS x,
table.field_b AS y,
tableb.field_a AS a,
tableb.field_b AS b
FROM
table CROSS JOIN tableb
If in fact tableb
has multiple rows, each correlated in some way with exactly one row of table
, then you would instead perform an [INNER] JOIN
using a join predicate corresponding to the appropriate relationship. If you want anything more specific then you'll need to describe your data better.
Upvotes: 1