0

Good day.

SELECT * FROM banners WHERE seet='$seet'

Structure table banners here https://i.stack.imgur.com/KR6Xu.png

Tell me please how get random one row from table?

  • 2
    Exact copy of http://stackoverflow.com/questions/19412/how-to-request-a-random-row-in-sql ? – Dan Jan 29 '13 at 07:27
  • 2
    What [RDBMS](http://en.wikipedia.org/wiki/Relational_database_management_system) you are using? `SQL Server`? `MySQL`? `Oracle`? `DB2`? etc.. – John Woo Jan 29 '13 at 07:33

1 Answers1

1

SELECT TOP 1 * FROM [TableName] ORDER BY NEWID()

This assigns a GUID to each row, and will return a random record based on the TOP 1 and ORDER BY combined.

SQLGuru
  • 1,099
  • 5
  • 14