Incorrect Usage of UNION and LIMIT

Asked

Viewed 108 times

3

I want my query to return only the first record of the first table (if there is data in it), because the second table has no repeated data.

But he returns this mistake:

Error Code: 1221. Incorrect Usage of UNION and LIMIT

My code:

SELECT administradores_id FROM adm LIMIT 1
UNION
SELECT usuarios_id FROM user;
  • If you want only the first record of the first table, why do Union?

1 answer

3


(SELECT administradores_id FROM adm LIMIT 1)
UNION
SELECT usuarios_id FROM user;

I put in the Github for future reference.

There is an ambiguity that the parser cannot solve alone, you have to help with a less ambiguous syntax.

I have my doubts whether this is a query that gives some useful result, but do not know details.

  • It worked here. Thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.