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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subselects don't work

Status
Not open for further replies.

rastkocvetkovic

Programmer
Aug 11, 2002
63
SI
Hello!

I'm experiencing a problem on Apache (1.3.26) + mySQL (3.23.39) + PHP (4.2.2).

The following SQL statement...
SELECT id FROM News WHERE id = (SELECT MAX(id) FROM News)

...returns an error saying:

You have an error in your SQL syntax near 'SELECT MAX(id) FROM News)' at line 1

In the mySQL documentation it says that SUBSELECTS work without any problem. Is there anything I can do? Thank you for your help!

Rastko
 
Actually the problem isn't SELECT MAX(id) FROM News, but the SUBSELECT itself (because SELECT MAX works fine if I exec it itself).
The following syntax also reports a similar error:

SELECT *
FROM Options
WHERE id NOT IN (SELECT options_id FROM settings WHERE User = 1)

Thank you for following posts!
 
what is the whoole query, there may be ways around it as 3.2.3xx doesn't support sub selects. ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Yep, we've come to the conclusion that subselects are in coming in 4.x only! Thanks anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top