Last record entered into database...?

Discussion in 'Databases - SQL Server 2008 / MySQL' started by DesignWizard, Dec 28, 2007.

  1. DesignWizard CSNM Customer

    Quick question:

    Does anyone know if there is an easy way to pull out data from the last record entered into a table (MySQL)?

    It has an auto-increment ID so it's just a case of the last ID but not sure how to query that, have looked on the net but have given up.

    Thought you guys might be able to help.....

    TIA
  2. Andrew Taylor CS New Media Staff

    Try:

    SELECT * from TABLE ORDER By ID DESC LIMIT 1

    That will pick the highest number ID
  3. DesignWizard CSNM Customer

    Thanks Andrew. Worked a treat - You're a star! :thumbup1:

Share This Page