Jump to content

Join on multiple fields


hitman6003

Recommended Posts

it's easiest if I just put up an example:

 

SELECT * FROM db

LEFT JOIN db2 ON db.field1 = db2.id

 

That works fine, but I have another field in "db" that I need to join to "db2".

 

I've tried:

SELECT * FROM db

LEFT JOIN db2 ON db.field1 = db2.id

LEFT JOIN db2 ON db.field2 = db2.id

 

And:

SELECT * FROM db

LEFT JOIN db2 ON db.field1 = db2.id, db.field2 = db2.id

 

And:

 

SELECT * FROM db

LEFT JOIN db2 ON db.field1, db.field2 = db2.id

 

 

But I get an error with each one.

 

Thanks for the help.

Link to comment
https://forums.phpfreaks.com/topic/2916-join-on-multiple-fields/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.