| | |
Distinct random rows
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2009
Posts: 3
Reputation:
Solved Threads: 0
I have a query that gets 5 random values out of a table according to a query. i.e.
This is fairly simplified but you get the idea. One of the fields in the table is ip, how can I do that same but ensure that all the ip values are DISTINCT. Any ideas anybody?
sql Syntax (Toggle Plain Text)
SELECT * FROM links WHERE url contra = FALSE ORDER BY RAND() LIMIT 0,5
This is fairly simplified but you get the idea. One of the fields in the table is ip, how can I do that same but ensure that all the ip values are DISTINCT. Any ideas anybody?
Last edited by peter_budo; Jan 6th, 2009 at 9:28 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
•
•
Join Date: Aug 2007
Posts: 165
Reputation:
Solved Threads: 18
•
•
•
•
I have a query that gets 5 random values out of a table according to a query. i.e.
sql Syntax (Toggle Plain Text)
SELECT * FROM links WHERE url contra = FALSE ORDER BY RAND() LIMIT 0,5
This is fairly simplified but you get the idea. One of the fields in the table is ip, how can I do that same but ensure that all the ip values are DISTINCT. Any ideas anybody?
sql Syntax (Toggle Plain Text)
SELECT DISTINCT ip, * FROM links WHERE url contra = FALSE ORDER BY RAND() LIMIT 0,5
![]() |
Other Threads in the MySQL Forum
- Previous Thread: way to inserting data into a MYSQL table data in an ordered way
- Next Thread: Updating 12k records twice a day
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





