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

SQL error message :: MySql

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
Select IID from Images
where IID in (select max(IID) from Images)

MySQL said:


You have an error in your SQL syntax near '(max(IID) from Images) LIMIT 0, 30' at line 2

This used to work fine NT but on MySQL it is spitting the dummy. Any idea's?
 
Hi There

The problem is that MySQL does not yet have sub-selects, so you have to write the query in two steps:

1. Get the maximum price value from the table with a SELECT statement.

select max(IID) from Images

2. Using this value compile the actual query:


Another solution is to sort all rows descending by IID and only get the first row using the MySQL specific LIMIT clause:

SELECT IID
FROM images
ORDER BY IID DESC
LIMIT 1


Hope This Helps

Bernadette
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top