Page 1 of 1

DISTINCT

Posted: Mon Aug 09, 2010 4:01 pm
by hallsofvallhalla
Don't know why I had trouble with this but thought I would share

if you ever need to select a field only once yu can use DISTINCT.

so lets say you have a DB with a table for a auction full of items and many of them are the same item.

Lets say you want to list all items in the auction but not repeat all the ones that are the same

select DISTINCT name, seller from auction

works like a charm. Most of you may already know this, I had known of that keyword. Thought I would share. :P

Re: DISTINCT

Posted: Mon Aug 09, 2010 7:52 pm
by Jackolantern
I read about it in the huge PHP/MySQL book I read, and while it sounds very useful, outside of reporting I have not had a need for it yet in PBBG development. For reporting it is indispensable, as it eliminates a ton of extra PHP code to get the same effect.

Re: DISTINCT

Posted: Mon Aug 09, 2010 10:20 pm
by hallsofvallhalla
yep, i am actually using it for a reporting site I am building for work.