...

View Full Version : Select Distinct.. Where?



tns123j
12-12-2004, 06:22 PM
i have a DB with table named Products. pCategory lists several names of teams of varing leagues (NBA, NFL, MLB, etc...) I want a table to display only the NBA teams. I have a field named pGroup which has NBA, MLB, etc... for each team. How can I display all fields where pGroup="NBA." I thought the code would work below, but it didn't. thanks.


<% sql_getProducts = "SELECT DISTINCT pCategory WHERE pGroup="NBA" FROM products"

glenngv
12-13-2004, 02:20 PM
Try this:

sql_getProducts = "SELECT DISTINCT pCategory FROM products WHERE pGroup='NBA'"

ghell
12-13-2004, 04:43 PM
also, if you use "" inside a string it escapes it into a single "
so glen's
sql_getProducts = "SELECT DISTINCT pCategory FROM products WHERE pGroup='NBA'"
is the same as
sql_getProducts = "SELECT DISTINCT pCategory FROM products WHERE pGroup=""NBA"""
.. i think.. im not sure since its in a string for an sql query (i dont know if it needs to be ')



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum