I have a query which uses three lookup tables to get all the information I need. I need to have DISTINCT values for one column, however I also need the rest of the data associated with it.
My SQL code:
SELECT acss_lookup.ID AS acss_lookupID, acss_lookup.product_lookupID AS acssproduct_lookupID, acss_lookup.region_lookupID AS acssregion_lookupID, acss_lookup.document_lookupID AS acssdocument_lookupID, product.ID AS product_ID, product.parent_productID AS productparent_product_ID, product.label AS product_label, product.displayheading AS product_displayheading, product.displayorder AS product_displayorder, product.display AS product_display, product.ignorenewupdate AS product_ignorenewupdate, product.directlink AS product_directlink, product.directlinkURL AS product_directlinkURL, product.shortdescription AS product_shortdescription, product.logo AS product_logo, product.thumbnail AS product_thumbnail, product.content AS product_content, product.pdf AS product_pdf, product.language_lookupID AS product_language_lookupID, document.ID AS document_ID, document.shortdescription AS document_shortdescription, document.language_lookupID AS document_language_lookupID, document.document_note AS document_document_note, document.displayheading AS document_displayheading FROM acss_lookup INNER JOIN product ON (acss_lookup.product_lookupID = product.ID) INNER JOIN document ON (acss_lookup.document_lookupID = document.ID) ORDER BY product_displayheading ASC; I want to get all the products from this query but I only want to get them once because I'm populating a drop down menu for a search application. I want the user to be able to select from the products that are in that table (that's why I only need them once).
Is this too complicated? Should I use a more simplified approach?