yatzr Posted September 27, 2007 Share Posted September 27, 2007 I've got two tables, table a and table b. Table a has two fields, personA and personB. Table b has two fields, personName and personID. personA and personB are numbers that correspond to personID. personName is the name associated with that ID. It's set up this way so that different people (identified by personID) can have the same name. What I need is to somehow join the two tables to get personA, personA's personName, personB, and personB's personName. I just started looking at doing a Join, but I don't see how I could get one to work for this. Does anyone have a good idea on how to accomplish this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/70940-solved-can-this-be-solved-with-a-join/ Share on other sites More sharing options...
fenway Posted September 27, 2007 Share Posted September 27, 2007 I can show you the join... but I don't understand what table A is for. Quote Link to comment https://forums.phpfreaks.com/topic/70940-solved-can-this-be-solved-with-a-join/#findComment-356678 Share on other sites More sharing options...
yatzr Posted September 27, 2007 Author Share Posted September 27, 2007 table a keeps track of matches between two people. There's more columns in that table, but only the IDs are important here. I want to display the matches, and I have the IDs, now I just need to turn those IDs into names. The IDs and Names are already stored in a separate table...table b. Quote Link to comment https://forums.phpfreaks.com/topic/70940-solved-can-this-be-solved-with-a-join/#findComment-356682 Share on other sites More sharing options...
fenway Posted September 27, 2007 Share Posted September 27, 2007 Understood... SELECT a.personA, ba.personName AS personAName, b.personB, bb.personName AS personBName FROM tableA AS s JOIN tableB AS ba ON ( ba.personID = a.personA ) JOIN tableB AS bb ON ( bb.personID = a.personB ) Quote Link to comment https://forums.phpfreaks.com/topic/70940-solved-can-this-be-solved-with-a-join/#findComment-356686 Share on other sites More sharing options...
yatzr Posted September 27, 2007 Author Share Posted September 27, 2007 it works! I had to change it to "a.personB" and "tableA AS a", but I'm assuming those were typos. I don't think I ever could have come up with that...so much to learn . Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/70940-solved-can-this-be-solved-with-a-join/#findComment-356694 Share on other sites More sharing options...
fenway Posted September 27, 2007 Share Posted September 27, 2007 it works! I had to change it to "a.personB" and "tableA AS a", but I'm assuming those were typos. I don't think I ever could have come up with that...so much to learn . Thanks! Yeah, sorry about that, long day. Quote Link to comment https://forums.phpfreaks.com/topic/70940-solved-can-this-be-solved-with-a-join/#findComment-356706 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.