Nevermind, I found in the documentation that I need to
paranthesize the SELECT parts of the UNION ALL, like
this:

(SELECT X, Y FROM A WHERE W = 1 LIMIT 1000)
UNION ALL
(SELECT X, Y FROM B WHERE W = 1 LIMIT 1000)
ORDER BY X



--- "Homam S.A." <[EMAIL PROTECTED]> wrote:
> MySQL seems to let me use the LIMIT clause in both
> parts of a UNION ALL query, but as soon as I add an
> ORDER BY CLAUSE, it gives me a syntax error.
> 
> For example, this query executes fine:
> 
> SELECT * FROM A WHERE X = 1 LIMIT 1000
> UNION ALL
> SELECT * FROM B WHERE Y = 1 LIMIT 1000
> 
> But this returns an error:
> 
> SELECT X, Y FROM A WHERE W = 1 LIMIT 1000
> UNION ALL
> SELECT X, Y FROM B WHERE W = 1 LIMIT 1000
> ORDER BY X
> 
> Any way to let sort the result other than a temp
> table?
> 
> Thanks,
> 
> Homam
> 
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:   
>
http://lists.mysql.com/[EMAIL PROTECTED]
> 
> 

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to