hitman6003 Posted November 22, 2005 Share Posted November 22, 2005 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. Quote Link to comment https://forums.phpfreaks.com/topic/2916-join-on-multiple-fields/ Share on other sites More sharing options...
sqlmc Posted November 23, 2005 Share Posted November 23, 2005 Try this: SELECT * FROM db LEFT JOIN db2 ON db.field1 = db2.field1 AND db.field2 = db2.field2 Quote Link to comment https://forums.phpfreaks.com/topic/2916-join-on-multiple-fields/#findComment-9791 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.