Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Counter In SQL

  • 01-11-2006 02: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