MySQL 3.23 UNION not working with error 1064

I am trying to use the UNION operator in an old BugZilla MySQL DB with MySQL 3.23. Here is a simplified version of what I'm trying to do. This is really nothing exotic, but MySQL continues to say 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 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

It is really as simple as you can get a union statement. Any ideas?

EDIT: I used a very similar query based on MySQL 5 DB, and it worked fine. Are these special UNION syntaxes for MySQL 3 that don't appear in Google documentation or search?

-1
source share
3 answers

, UNION MySQL 3, , MySQL 3 UNION:) .

UNION SELECT . UNION MySQL 4.0.0.

article .

0

:

SELECT DISTINCT bug_id, rep_platform
    FROM bugs
    WHERE rep_platform IN ('XX', 'YY');
+3

I think you meant

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

Joe’s answer is much simpler and more enjoyable. +1 for Joe.

The two changes I made are

  • I dropped all parentheses
  • I put an alias of table A next to errors in the first SELECT
0
source

All Articles