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!

SQL Select

Status
Not open for further replies.

efeerdogru

Programmer
Dec 8, 2003
1
TR
Hi all,

Can anyone tell me why this SQL query doesn't work in mySQL? No syntax error; it works in Access.

It is a simple query. Original is more complex. Reading from another table in the brackets. But with this case, I get error. Is there a different usage in mySQL for these type of queries?

------------------------------
Select * From Hotels Where HotelID = (Select HotelID From Hotels Where HotelID = 1)
------------------------------

mySQL gives this error:
------------------------------

SQL query:

SELECT *
FROM Hotels
WHERE HotelID = (
SELECT HotelID
FROM Hotels
WHERE HotelID =1 )
LIMIT 0 , 30

MySQL result:


#1064 - You have an error in your SQL syntax near 'SELECT HotelID
FROM Hotels
WHERE HotelID =1 ) LIMIT 0, 30' at line 4
 
depends on your mysql version. subselects are only available from version 4.....
see for more info about subselects and how to work around it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top