hello, i was trying to run this query:
(
(SELECT * FROM (SELECT * FROM `users` WHERE `access_level` > 0) AS `search_subject` WHERE (BINARY `username` = ?))
UNION
(SELECT * FROM (SELECT * FROM `users` WHERE `access_level` > 0) AS `search_subject` WHERE (BINARY `username` = ?))
)
LIMIT 5
but got an error because of the surrounding parenthesis, just before LIMIT 5
. obs: the query is all in a row, i endented it here for better reading. is it allowed in sql?
the following works fine:
(SELECT * FROM (SELECT * FROM `users` WHERE `access_level` > 0) AS `search_subject` WHERE (BINARY `username` = ?))
UNION
(SELECT * FROM (SELECT * FROM `users` WHERE `access_level` > 0) AS `search_subject` WHERE (BINARY `username` = ?))
LIMIT 5
my question is: this second version is equivalent to the first one or does the LIMIT in the second version only applies in the second SELECT
? if so, what can i do to work around this? thanks (:
ps: don't worry about the interrogation marks. that's just because of the prepared statements