Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subquery

Status
Not open for further replies.

hilbrink

Programmer
Dec 8, 2000
38
NL
when trying to execute the query

SELECT *
FROM A, B
WHERE A.id = B.idA
AND (SELECT count(*) FROM A WHERE A.id=B.idA) < 2

i get the message ORA-00936: missing expression. And the point where the exception is given is the SELECT statement in the subquery.

Does anybody know why i get this message? In the syntax description of the SELECT statement it says i can use a subquery...
 
Try...

SELECT *
FROM A, B
WHERE A.id = B.idA
AND (SELECT count(*) FROM A2 WHERE A2.id=B.idA) < 2

I think the duplicate aliases are confussing it all.

 
OK Try having your subquery on the right hand side of the equals...
 
select * from a,b
where a.id=b.id and
exists(select id from a where a.id=b.id group by id having count(*)<2)
 
OK Try having your subquery on the right hand side of the equals...

Sorry not the equals the less than sign, although you will need to change your logic slightly...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top