I have a list of items for businesses in a database:
listings
`id` `location` `item` `status`
So in the database I might have something like:
19 Loc A Green Beans for $12 active
20 Loc B Two Gatoraids for $3 deactive
21 Loc A Ham for $2 per lb active
22 Loc A Pepsi 2 for $2 active
23 Loc C House plants $10 active
24 Loc B Milk Gallon for $1 active
25 Loc C Ice cream for $5 active
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?