Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL Query help, Please... 1

Status
Not open for further replies.

admoore

IS-IT--Management
May 17, 2002
224
US
Lets say I have a field in a table with records like this:

shirt XL blue
shirt M blue
shirt S red
pants 32L denim
socks S white

And I want a query to list all of the UNIQUE contents of the item field; i.e. the results would be:

shirt
pants
socks

This should not be too difficult; but I can't seem to get it...

Many TIA,

-Allen
 
the keyword you're looking for in your SQL statement is "distinct." here's an example of how to use it:

let's say your table is named CLOTHES, and the column that has "shirt, pants, socks" in it is called clothing_item.

$myquery = "select DISTINCT clothing_item from CLOTHES";

this will pull only one instance of each different kind of item in the clothing_item column.

hope this helps!
inger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top