how to select the newest entries ?

Morningdot Hablu

Morningdot Hablu

@morningdot-6Xuj4M Oct 20, 2024
hello friend's
Any one have idea how to select last 10 rows from our database without altering any new column in DB.

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Morningdot Hablu

    Morningdot Hablu

    @morningdot-6Xuj4M Apr 10, 2011

    No answer !!
  • Prasad Ajinkya

    Prasad Ajinkya

    @prasad-aSUfhP Apr 11, 2011

    in mysql, you have the LIMIT keyword, sort by the primary key in desc order and use LIMIT 10. that should do no?
  • Morningdot Hablu

    Morningdot Hablu

    @morningdot-6Xuj4M Apr 11, 2011

    I have tried
    select * from table order by id desc limit 10;
    and
    select * from table order by id limit 10;
    both but it doesn't works !!
  • slashfear

    slashfear

    @slashfear-tSWzpz Apr 12, 2011

    Hey Mohit,

    Can you specify what database your using because what kidakaka said is right !! in Mysql it will work!! if your using any other database for example in Microsoft SQLserver or SYBASE, LIMIT keyword is not supported so we have to use TOP keyword (mostly in databases it will either support TOP or LIMIT will be available) so this is how you can use your TOP keyword to accomplish the task what you asked for EG: select top 10 * from tablename order by id desc

    -Arvind