Joining tables

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Joining tables

Post by kpraman »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


[syntax="sql"]SELECT product_sizes.*, product_details.* FROM product_sizes LEFT JOIN product_details ON product_sizes.sizeId=product_details.size AND product_details.productId=$productId
Above code works perfectly. How can i include one more table and and condition to the aboce query?

I tried,

Code: Select all

SELECT product_sizes.*, product_details.*, products.* FROM product_sizes LEFT JOIN product_details ON product_sizes.sizeId=product_details.size AND product_details.productId=$productId AND products.productId=product_details.productId
its not working.


feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Post Reply