Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2012
    Posts
    2

    Unanswered: Left Join question

    Hello,
    I am using an Opencart shop for my online store, but the search engine looks only into the product names and description. I want to enhance the funcionality so it search the manufacterer too. But here is my problem:

    The query opencart makes is the following:

    Code:
    SELECT p.product_id FROM product p LEFT JOIN product_description pd ON (p.product_id = pd.product_id) LEFT JOIN product_to_store p2s ON (p.product_id = p2s.product_id) WHERE ...
    but there is no product_to_manufacturer table out there....there is just the manufacturers table! with all the manufacturers and their unique id.
    The products table has a column called "manufacturer" that references his manufacturer id.

    I have to enhance the query, I can't execute another query... is there a database guru who can help me out of this one??

    thank you, and sorry for my English!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT p.product_id 
      FROM product p 
    LEFT 
      JOIN product_description pd 
        ON pd.product_id = p.product_id 
    LEFT 
      JOIN product_to_store p2s 
        ON p2s.product_id = p.product_id
    LEFT
      JOIN manufacturers m
        ON m.manufacturer_id = p.manufacturer     
     WHERE ...
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Apr 2012
    Posts
    2

    :)

    thank you, works great.... can't believe was so easy

Tags for this Thread

Posting Permissions

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