webguync Posted June 24, 2008 Share Posted June 24, 2008 I have a table Join Query $sql = "SELECT ID, emp_name, emp_id FROM $employee_table LEFT JOIN $check_table ON `ID` = `EmpID` ORDER BY ID ASC"; and I want to add another column to Join,so it would be ON `emp_name` = `EmpName` would I need to do a separate $sql or can I combine what I have above somehow? Link to comment https://forums.phpfreaks.com/topic/111741-solved-table-join-question/ Share on other sites More sharing options...
cooldude832 Posted June 24, 2008 Share Posted June 24, 2008 that is bad table structure if you need to join like that. Key to Key joins are best. explain your reasoning Link to comment https://forums.phpfreaks.com/topic/111741-solved-table-join-question/#findComment-573647 Share on other sites More sharing options...
webguync Posted June 25, 2008 Author Share Posted June 25, 2008 well, I have another post http://www.phpfreaks.com/forums/index.php/topic,203543.0.html on the PHP forums, explaining what I am trying to accomplish posting information from a select form. I thought another join might be what I need, but I didn't know for sure, or even if it was possible. Link to comment https://forums.phpfreaks.com/topic/111741-solved-table-join-question/#findComment-573723 Share on other sites More sharing options...
fenway Posted June 25, 2008 Share Posted June 25, 2008 You can combine multiple conditions in the ON clause like in a WHERE clause. Link to comment https://forums.phpfreaks.com/topic/111741-solved-table-join-question/#findComment-574337 Share on other sites More sharing options...
webguync Posted June 26, 2008 Author Share Posted June 26, 2008 would that be something like $sql = "SELECT ID, emp_name, emp_id FROM $employee_table LEFT JOIN $check_table ON `ID` = `EmpID` AND ON `emp_name` = `EmpName`ORDER BY ID ASC"; ?? Link to comment https://forums.phpfreaks.com/topic/111741-solved-table-join-question/#findComment-575022 Share on other sites More sharing options...
fenway Posted June 26, 2008 Share Posted June 26, 2008 No... like "ON ( `ID` = `EmpID` AND `emp_name` = `EmpName` )" Link to comment https://forums.phpfreaks.com/topic/111741-solved-table-join-question/#findComment-575063 Share on other sites More sharing options...
webguync Posted June 26, 2008 Author Share Posted June 26, 2008 ok, thanks Link to comment https://forums.phpfreaks.com/topic/111741-solved-table-join-question/#findComment-575070 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.