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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DISTINCT trouble 1

Status
Not open for further replies.

PhatH

IS-IT--Management
Mar 30, 2004
88
US
EX: I have 3 tables, Products, Manufacturers and ProductType.
In the tblProducts containing both ManuID and ProdTypeID that links to the other two tables.
When I call to display ProdTypeNames that associate with a particular Manufacture, the tblProducts might have the products that are the same Manufacture and ProdType, and I don't want to show the ProdTypeName more than once.

by using sql2000,

sql = "SELECT DISTINCT tblProductType.ProdTypeName, tblProducts.ProductID, tblProducts.ManuID FROM tblProducts, tblProductType WHERE tblProducts.ProdTypeID = tblProductType.ProdTypeID and tblProducts.ManuID = '" & request.querystring("ManuID") & "'"

Could you tell me why the DISTINCT tblProductType.ProdTypeName is not working?
 
you're grabbing distinct productID and manuID right now.
 
DISTINCT applies to all the columns being selected.

For example:

col1 col2 col3
1 a Ann
1 a Adam
2 b Bill
2 b Bill

SELECT DISTINCT col1, col2, col3
returns:
col1 col2 col3
1 a Ann
1 a Adam
2 b Bill

Those three rows are DISTINCT. The fourth row was a duplicate so it was eliminated.

SELECT DISTINCT col1
returns
col1
1
2

SELECT DISTINCT col1, col2
returns
col1 col2
1 a
2 b

-SQLBill
 
Is there a way to isolate which data I want to DISTINCT in one SQL query?
 
Thank amorous,

The link you gave me was almost the same as my problem. As same as that person, I don't understand half of the SQL query. I tried to modify that final query to match to my requirement but nothing seems to work for me yet.

I got to move on to something else now. But DO want to see anyone else with different approaches... Thank you all!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top