Search code examples
mysqlmysql-error-1064

MySQL 3.23 UNION fails with Error 1064


I am trying to use a UNION statement in an old BugZilla MySQL DB running MySQL 3.23. Here is a simplified version of what I am trying to do. It's really nothing exotic but MySQL keeps saying that something is wrong.

(select bug_id,rep_platform from bugs where rep_platform='XX') 
 UNION 
(select bug_id,rep_platform from bugs where rep_platform='YY');

The result I get is:

ERROR 1064 (HY000): You have an error in your SQL syntax near '(select bug_id,rep_platform from bugs where rep_platform='XX')
UNION
(select bu' at line 1

This is really about as simple of a union statement as you can get. Any ideas?

EDIT: I ran a very similar query on a MySQL 5 DB and it worked just fine. Is these some special UNION syntax on MySQL 3 that doesn't show up in documentation or Google searches?


Solution

  • The reason why the UNION is not working in MySQL 3 is because MySQL 3 does not support UNION statements :) Take a look at the official documentation.

    UNION is used to combine the result from multiple SELECT statements into a single result set. UNION is available from MySQL 4.0.0 on.

    Take a look at this article for workarounds.