Jim R Posted March 19, 2020 Share Posted March 19, 2020 I need to match the city and school in two tables (CONCAT) so I can determine whether or not they use the toggle column. Toggle is in a_schools city and school are in both The others are in a_players (I'm sure someone will ask why a_players table doesn't have/use teamID, but it's not effective for my people (or me) to enter names.) With LEFT JOIN it gives me the list I should get, 15 rows. However, the toggles are all NULL. Two should have "1". Here is the query: SELECT nameFirst,nameLast,feet,inches,p.city,p.school,grade,position,grouping,rankPos,toggle FROM a_players p LEFT JOIN a_schools s ON CONCAT(p.city,p.school) = CONCAT(s.school,s.school) WHERE position ='3' AND grade='23' AND grouping ='2' ORDER BY rankPos Quote Link to comment https://forums.phpfreaks.com/topic/310328-an-issue-with-join-two-tables/ Share on other sites More sharing options...
Barand Posted March 19, 2020 Share Posted March 19, 2020 (edited) Sounds like there are no matching schools records - perhaps if you had CONCAT(s.city,s.school) instead of CONCAT(s.school,s.school) it may find matches. or ...LEFT JOIN a_schools USING (city, school) Edited March 19, 2020 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/310328-an-issue-with-join-two-tables/#findComment-1575623 Share on other sites More sharing options...
Jim R Posted March 20, 2020 Author Share Posted March 20, 2020 Ugh...I hate typos. Thanks, as always. I figured it was something simple. Quote Link to comment https://forums.phpfreaks.com/topic/310328-an-issue-with-join-two-tables/#findComment-1575628 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.