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!

[MySQL] SUBSELECT & MAX()

Status
Not open for further replies.

nariman

Programmer
Oct 30, 2002
2
NL
Hi people,

I’m working with MySQL and I want to select all rows of the table except the last one. In ANSI SQL dialect I would use the following query:

[tt]
SELECT *
FROM table
WHERE row_id != (SELECT MAX(row_id)
FROM table)[/tt]

But I have to rewrite it for MySQL. Can someone plz help me?
 
SELECT *
FROM table
WHERE row_id != MAX(row_id)
______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 

SELECT *
FROM table
WHERE row_id != MAX(row_id)


This wont work, because you cant use MAX() in the WHERE-row.

Anyone else? Plzzzzzzz !!!
 
SELECT *,@max:=MAX(row_id)
FROM table
WHERE row_id != @max

just be creative :)
______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top