SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast MAC#1's Avatar
    Join Date
    Mar 2003
    Location
    ontario
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question multiple join... almost there

    OK. I have the following multiple joins working seperately but not together as in the last example (which is what I really need).
    PHP Code:
    $result=mysql_query("SELECT * FROM cust_cart INNER JOIN products ON cust_cart.number = products.code_no WHERE cust_cart.cart_id = $cart_id");

    $result=mysql_query("SELECT * FROM cust_cart INNER JOIN zoom ON cust_cart.number = zoom.number WHERE cust_cart.cart_id = $cart_id"); 
    I need the cust.cart ID to be the main focus picking up the variables from products and zoom tables.

    PHP Code:
    $result=mysql_query("SELECT cust_cart.number FROM cust_cart, products, zoom WHERE cust_cart.cart_id = $cart_id and cust_cart.number = products.code_no OR cust_cart.number = zoom.number"); 
    All help appreciated.

  2. #2
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
     $result=mysql_query("SELECT cust_cart.number FROM cust_cart, products, zoom WHERE cust_cart.cart_id = $cart_id and (cust_cart.number = products.code_no OR cust_cart.number = zoom.number)" ); 
    ?
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  3. #3
    SitePoint Enthusiast MAC#1's Avatar
    Join Date
    Mar 2003
    Location
    ontario
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tried your ex. sweatje but it didn't work for me.


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
  •