MySQL Select by random

pompe a biere

New Member
I have a list of items for businesses in a database:\[code\]listings `id` `location` `item` `status`\[/code\]So in the database I might have something like:\[code\]19 Loc A Green Beans for $12 active20 Loc B Two Gatoraids for $3 deactive21 Loc A Ham for $2 per lb active22 Loc A Pepsi 2 for $2 active23 Loc C House plants $10 active24 Loc B Milk Gallon for $1 active25 Loc C Ice cream for $5 active\[/code\]No what I want to do is list the items, BUT only one item per location, and if there is more than one item for a location I want it have the item be at random. Plus only display item that the status = active.Now is my table set up to be able to do this efficiently or should I go another route?
 
Back
Top