Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2004
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Select Distinct.. Where?

    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"

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Try this:

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

  • #3
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    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 ')


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •