Jump to content

patrickin

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Everything posted by patrickin

  1. There is one rule that you should follow that I promise you will fix your problem. The amount of queries called should not increase as the amount of data increases. Basically this means, NO QUERIES INSIDE OF DYNAMIC LOOPS!
  2. I am querying my DB to get some listings. But because a listing can fall into up to 5 sub categories, they can be returned up to 5 times by the following query, however I need duplicates removed, via DISTINCT. However I cannot figure out how to place DISTINCT in this query, so that it actually works, as I am still getting duplicates. Currently no errors are being thrown out, I'm just getting dupes, and I think my SQL ver and table structure is irrelevant for this question. SELECT DISTINCT listings.*, categories.ID as catID, subcategories.ID as subID, subcategories.categoryID as sccatID FROM listings, categories, subcategories WHERE listings.active = 1 AND subcategories.categoryID = 1 AND categories.ID = 1 AND (listings.subcategory1ID = subcategories.ID OR listings.subcategory2ID = subcategories.ID OR listings.subcategory3ID = subcategories.ID OR listings.subcategory4ID = subcategories.ID OR listings.subcategory5ID = subcategories.ID Thanks for any help!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.