Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Counter In SQL

  • 01-11-2006 03:45PM
    #1
    Closed Accounts Posts: 73 ✭✭


    Can some one please tell me how to display a random number of records from a database using SQL.


Comments

  • Registered Users, Registered Users 2 Posts: 379 ✭✭TheWaterboy


    do u mean something like this:

    SELECT * FROM tbl_name ORDER BY RAND() LIMIT 15


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    Very much depends on which system you're using, but fundamentally you're gonna use a TOP, LIMIT, ROWNUM or whatever your DB offers against a RAND function of some description as just described.

    Seems like an odd thing to want to do though.

    jc


  • Closed Accounts Posts: 73 ✭✭gerryjuice


    Just need to get a representation of the data within a table, so needed to get a random selection.
    Thanks for the help.


Advertisement