I know there are several question like this one but I feel I’ve spent more than enough time trying different examples for a simple little hobby project. Yes, I’m being lazy, but in my defense, It’s Saturday morning…
So I’ve got a table, Items which have the following fields (and more irrelevant ones):
id (varchar), product (varchar), provider (varchar)
Items are part of products, and have a provider.
I want to write a query where I can get one item per product a given provider supplies.
So even if a provider supplies all items for a product, I just want one of those.
I know I can’t do distinct on only one field but I’ve tried with different variants o joins.
Should be simple for those of you who actually know what you’re doing.
mysql have gone to the trouble of creating a website that contains a manual and all references to its features.
for distinct:
http://dev.mysql.com/doc/refman/5.0/en/distinct-optimization.html