What's wrong with this syntax? 
Author Message
 What's wrong with this syntax?

SELECT id_1 FROM table1 WHERE state_code IN ('AZ','DE')
UNION
SELECT id_1 FROM table1 WHERE zip_code IN ('12345','54321');

Above SQL statement running fine.
Now I added

SELECT id_2 FROM table2 WHERE id_1 IN (
SELECT id_1 FROM table1 WHERE state_code IN ('AZ','DE')
UNION
SELECT id_1 FROM table1 WHERE zip_code IN ('12345','54321')
);

Now I got parse error at or near "union"
Please tell me what's wrong with the 2nd SQL statement.
Thank you!

--Raymond

  raymond.chui.vcf
< 1K Download


Fri, 09 Jan 2004 22:00:46 GMT
 What's wrong with this syntax?


Quote:

> SELECT id_1 FROM table1 WHERE state_code IN ('AZ','DE')
> UNION
> SELECT id_1 FROM table1 WHERE zip_code IN ('12345','54321');

> Above SQL statement running fine.
> Now I added

> SELECT id_2 FROM table2 WHERE id_1 IN (
> SELECT id_1 FROM table1 WHERE state_code IN ('AZ','DE')
> UNION
> SELECT id_1 FROM table1 WHERE zip_code IN ('12345','54321')
> );

can you represent the relations(tables) you are working on

Frank



Sat, 10 Jan 2004 16:03:43 GMT
 What's wrong with this syntax?

Quote:

> SELECT id_2 FROM table2 WHERE id_1 IN (
> SELECT id_1 FROM table1 WHERE state_code IN ('AZ','DE')
> UNION
> SELECT id_1 FROM table1 WHERE zip_code IN ('12345','54321')
> );

> Now I got parse error at or near "union"

Thank you too all replied to me.
Just let all you know the above SQL statement is work in PostgreSQL
7.1.x
above, and won't work on PostgreSQL 7.0.x below.

--Raymond

  raymond.chui.vcf
< 1K Download


Sat, 10 Jan 2004 19:28:40 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. What's wrong with my syntax ???

2. What's wrong with this syntax?

3. Problems using new v7.2 features (or, What's wrong with this syntax?)

4. SQL Syntax Help - Incorrect syntax near '%'.

5. run-time error 3001, syntax is wrong?

6. wrong DAO error: Syntax error in number in query expression

7. Whats wrong with the syntax ?

8. wrong SQL syntax or ...?

9. Sqlj claims sql syntax wrong

10. Whats wrong with BCP syntax ?

11. What is wrong with my simple SQL syntax?


 
Powered by phpBB® Forum Software