atitthaker Posted August 29, 2006 Share Posted August 29, 2006 I didn't find anyother place to post the query so I am posting it here.This is my table like:ID name1 t13 t25 t37 t42 t5Now I want to find out the row with 3rd maximum ID. In this case the raw with id 3.I tried many ways but I am unable to get work arround this. MySQL is not supporting IN construct with my version.Plz HelpThanks Quote Link to comment Share on other sites More sharing options...
fenway Posted August 29, 2006 Share Posted August 29, 2006 First, all versions support the IN clause. Second, why do you ever want to 3rd largest ID? Third, the following should work:[code]SELECT * FROM yourTable ORDER BY ID LIMIT 3,1[/code]Assuming that there are at least 3 entries in your table. Quote Link to comment Share on other sites More sharing options...
extrovertive Posted August 31, 2006 Share Posted August 31, 2006 SELECT `ID`, `name`FROM tORDER BY ID ASCLIMIT 2, 1 Quote Link to comment Share on other sites More sharing options...
extrovertive Posted September 1, 2006 Share Posted September 1, 2006 I'm also doing an experiement.How do I increment the max ID value in the table.I tried:UPDATE t SET ID = ID + 1WHERE ID = (SELECT MAX(ID) FROM t)but i get#1093 - You can't specify target table 't' for update in FROM clause Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 1, 2006 Share Posted September 1, 2006 Off the top of my head, I'd say the error message you reported is telling you exactly what the problem is ... and the fix shouldn't be far away from reading that message. Quote Link to comment Share on other sites More sharing options...
fenway Posted September 1, 2006 Share Posted September 1, 2006 Not that you're ever supposed to, but you can just "SET" the auto_increment value directly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.