Thread: SQL question

Page 1 of 7 123 ... LastLast
Results 1 to 10 of 68
  1. #1
    Join Date
    Mar 2009
    Posts
    393
    Plugin Contributions
    0

    Default SQL question

    Is there a way to query the database to list all the different entries from a field in a table and ignore duplicates?

    For example a table with the following entries

    cat
    dog
    cat
    cat
    rabbit
    dog
    elephant
    cat
    cat
    dog
    dog


    would output a list reading

    cat
    dog
    rabbit
    elephant

  2. #2
    Join Date
    Aug 2005
    Posts
    26,245
    Plugin Contributions
    9

    Default Re: SQL question

    For what reason???
    And is this to be included as some feature in the cart or only for you?

    If in the cart please explain in much more detail what it is you are seeking
    Zen-Venom Get Bitten
    Get Your Business Found

  3. #3
    Join Date
    Mar 2009
    Posts
    393
    Plugin Contributions
    0

    Default Re: SQL question

    Each product I sell has a model code, this code is often shared by more than one product.

    What I wanted was to list all the different model codes that I have on the store so someone can see at a glance if we stock products for that model code. If they see their model code they can click that code and the site will search the website for that code.

    If you imagine the example I gave earlier and you sold products for different animals, different products could all be found under "cats" I would like a list to be generated for all the different animals I sold products for.

    so even though you may have 1000 products there may only be 15 different animals, so the list i would like generated would be 15 items long listing the different animals, not 1000 items long listing each products animal, resulting in many duplicates.

  4. #4
    Join Date
    Aug 2005
    Posts
    26,245
    Plugin Contributions
    9

    Default Re: SQL question

    Each product I sell has a model code, this code is often shared by more than one product.
    Shared??

    Is this the same product or a totally different product with the same code?
    Zen-Venom Get Bitten
    Get Your Business Found

  5. #5
    Join Date
    Mar 2009
    Posts
    393
    Plugin Contributions
    0

    Default Re: SQL question

    different products.

    If you imagine

    Product 1 = Water Bowl - (code = dog)
    Product 2 = Bed - (code = dog)
    Product 3 = toy - (code = cat)
    Product 4 = ball - (code = rabbit)
    Product 5 = ball - (code = dog)
    Product 6 = water bowl - (code = cat)

    list generated

    dog
    cat
    rabbit

    instead of

    dog
    dog
    cat
    rabbit
    dog
    cat

    I want it to list all individual entries in the table field.

  6. #6
    Join Date
    Aug 2005
    Posts
    26,245
    Plugin Contributions
    9

    Default Re: SQL question

    I suggest that you create/arrange your products in master categories of dog, cat, & rabbit then link them to other areas
    http://tutorials.zen-cart.com/index.php?article=216
    Zen-Venom Get Bitten
    Get Your Business Found

  7. #7
    Join Date
    Mar 2009
    Posts
    393
    Plugin Contributions
    0

    Default Re: SQL question

    Not applicable.

    Just trying to find a way to query the database to return all the info from a field and filter out duplicates.

  8. #8
    Join Date
    Mar 2009
    Posts
    393
    Plugin Contributions
    0

    Default Re: SQL question

    SELECT DISTINCT

    I think that is where I need to start looking

    http://www.tech-recipes.com/rx/1481/...tinct-keyword/

  9. #9
    Join Date
    Mar 2009
    Posts
    393
    Plugin Contributions
    0

    Default Re: SQL question

    http://www.w3schools.com/sql/sql_distinct.asp

    I need a php code to make that work

  10. #10
    Join Date
    Mar 2009
    Posts
    393
    Plugin Contributions
    0

    Default Re: SQL question

    I'm having trouble writing the php code, can anyone help?

 

 
Page 1 of 7 123 ... LastLast

Similar Threads

  1. Ask a Question [product] Question - Stop Guest Posts
    By ScrapbookSupplies in forum Addon Sideboxes
    Replies: 2
    Last Post: 22 Jun 2008, 04:13 AM
  2. Newbie question - spacing question...
    By coolcat in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 22 May 2007, 03:23 AM
  3. I'm not sure if this is a CSS question or an admin panel question....
    By kinget in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 24 Mar 2007, 08:29 PM

Bookmarks

Posting Permissions

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