SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Speed up query

  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Speed up query

    Hi!
    I have tryed to rewrite this Query to make it faster but i cant get it working:
    this is the line needed to be better:
    $sqlproduct = "select * from product where product.id IN (select pro_id from product_data where visible='yes' )";

    i have tryed this:
    $sqlproduct = "SELECT product.*
    FROM product LEFT JOIN product_data ON product.id=pro_id
    WHERE pro_id = visible='yes'";

    and this:
    SELECT DISTINCT product.* FROM product, product_data WHERE product.id=product_data.id;

    but cant figure out how to make this:
    (select pro_id from product_data where visible='yes' ) in the Query


    hope someone can help me

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,329
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Code:
    SELECT product.*
      FROM product 
    INNER
      JOIN product_data 
        ON product_data.pro_id = product.id
       AND product_data.visible = 'yes'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •