This is a discussion on how to get the last record only? within the Database Support forums, part of the Web Development category; This is my Example table structure code empname salary A01 S1 7500 A02 S2 5500 A00 S3 6500 how to ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| This is my Example table structure code empname salary A01 S1 7500 A02 S2 5500 A00 S3 6500 how to get the last record only.i will take the single query. pls help me. Note:All Database(Access,oracle,sql server,MySQL) |
| Sponsored Links |
| |||
| In MYSQL Code: SELECT * FROM <TableName> ORDER BY <TablePrimaryKeyField> DESC LIMIT 1; Code: SELECT * FROM <TableName> WHERE <TablePrimaryKeyField> =(SELECT MAX(TablePrimaryKeyField> FROM <TableName>);
__________________ -Murali.. |
| |||
| hi... For Mysql, consider the table name is SAMPLE. Query to get the last record of the table: Method 1: SELECT * FROM SAMPLE ORDER BY _ROWID DESC LIMIT 1; Method 2: SELECT * FROM SAMPLE WHERE _ROWID = (SELECT MAX(_ROWID) FROM SAMPLE); Note : _ROWID is keyword Regards, S.Ashokkumar Last edited by write2ashokkumar : 08-13-2007 at 07:14 AM. |
| |||
| hi, is there any way to get the nth record in mysql? for example i want to get 3 record from the total of 100 records. is there any generic way to find it in MySql?
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Hi , To get the N-th row from table in Mysql SET @N=3; -- for 3rd row from the table SET @M=@N-1; SET @S:='SELECT * FROM <Table_Name> LIMIT ?,1'; PREPARE STM FROM @S; EXECUTE STM USING @M; -------------- Thanks, V.Kumaresan. |
| |||
| Quote:
Got it thanks...
__________________ -Murali.. Last edited by Murali : 08-14-2007 at 04:20 AM. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how can i lock a record id using JSP? | saravanan | Java Server Pages (JSP) | 0 | 03-19-2008 10:03 PM |
| Audio Record in ASP.NET | kingmaker | ASP and ASP.NET Programming | 12 | 01-08-2008 05:45 AM |
| How To Record A Phone Conversation With A PC | vadivelanvaidyanathan | Computer Hardware | 1 | 09-18-2007 08:39 AM |
| Different record methods | Shanthi | Testing Tools | 1 | 08-27-2007 05:50 AM |
| Difference between ADO.NET dataset and ADO Record set? | prasath | ASP and ASP.NET Programming | 1 | 07-18-2007 08:06 AM |