CrazyEngineers
  • how to select the newest entries ?

    Updated: Oct 20, 2024
    Views: 1.4K
    hello friend's
    Any one have idea how to select last 10 rows from our database without altering any new column in DB.
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Morningdot Hablu

    MemberApr 10, 2011

    No answer !!
    Are you sure? This action cannot be undone.
    Cancel
  • Prasad Ajinkya

    MemberApr 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?
    Are you sure? This action cannot be undone.
    Cancel
  • Morningdot Hablu

    MemberApr 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 !!
    Are you sure? This action cannot be undone.
    Cancel
  • slashfear

    MemberApr 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
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register