0

I used

select * from equation_table order by type desc limit 1

But it returns 2nd record from the table.

Su93
  • 81
  • 1
  • 8

3 Answers3

1

If you have an autoincrement id in your table which is names as id. then you can simply run below SQL to get last inserted record.

SELECT * FROM TABLE_NAME WHERE id != 0 ORDER BY id DESC LIMIT 0,1
Saroj
  • 1,343
  • 4
  • 15
  • 31
  • 1
    yes. But I write it for syntax purpose. Though we want only 1 record then 1 is enough. – Saroj Sep 22 '17 at 05:35
1

try this :

SELECT * 
FROM equation_table 
WHERE Eqtbl_id != 0 
ORDER BY Eqtbl_id DESC
LIMIT 1

You can find more by this answer

iamsankalp89
  • 4,607
  • 2
  • 15
  • 36
0

if id is primary and autoincreament field then.

Select * from equation_table ORDER BY id DESC LIMIT 1;
Hardeep Singh
  • 743
  • 1
  • 8
  • 18