|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Getting random record from table.
Hi,
Can anybody help me? I have a one table with two field id---number (primary) Quotes- text it contaning 50 records. I want to get single record but in random order. every time it will give different record? plz, help me.. pritesh |
|
#2
|
||||
|
||||
|
Do you mean to do this directly in an SQL statement? Cause I dont' see that happening. There should be a way to do it in a stored procedure using cursors... you'll probably need a second table (a copy of the first) which you would then remove entries from so that you didn't get repeats... to tell you the truth I'd do this sort of thing in a programming language that talks to the database through ODBC or somthing
-mwalts |
|
#3
|
||||
|
||||
|
if your using Microsoft SQL Server check out the rand() keyword. If you're familia with C++/C it works the same way use the datepart() and getdate() to create a seed.
HTH |
|
#4
|
|||
|
|||
|
Hi,
If ur using SQLServer then use order by newid() function to get random rows Code:
select * from your_table where your_condtion order by newid() i hope it will helps u.... Cheers, Satish Kumar J. |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Getting random record from table. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|