marco839 Posted September 23, 2007 Share Posted September 23, 2007 Im really confused, can someone point me in the right direction? I have a login script which is seperate from another table which has details. (dont ask why, it makes it easier!) So when id 1 logs into the normal system, i want the script to pull details from another table in a different database with the same id. e.g.: Table 1 (users) Id | name 1 | mark 2 | jenny Table 2 (details) Id | detail 1 | Male 2 | female So when Jenny logs in, the script identifies ID2 from table 1 and displays info from line 2 (id) in table 2 if that makes sense!! Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/70362-id-of-one-table-pulling-the-id-of-another/ Share on other sites More sharing options...
AV1611 Posted September 23, 2007 Share Posted September 23, 2007 simple inner join select table1.name,table2.detail from table1 inner join table2 on table1.Id=table2.Id where table1.name = 'jenny' Quote Link to comment https://forums.phpfreaks.com/topic/70362-id-of-one-table-pulling-the-id-of-another/#findComment-353441 Share on other sites More sharing options...
AV1611 Posted September 23, 2007 Share Posted September 23, 2007 Actually, this would be better because if the table2 doesn't have an entry you get no output, this way you always at least get the table 1 data select table1.name,table2.detail from table1 left join table2 on table1.Id=table2.Id where table1.name = 'jenny' Quote Link to comment https://forums.phpfreaks.com/topic/70362-id-of-one-table-pulling-the-id-of-another/#findComment-353443 Share on other sites More sharing options...
marco839 Posted September 23, 2007 Author Share Posted September 23, 2007 Thanks very much - That helps with another part of my mini project, but I didn't mention something in error.. How would you link two different database details.. going along the same idea as before? Quote Link to comment https://forums.phpfreaks.com/topic/70362-id-of-one-table-pulling-the-id-of-another/#findComment-353446 Share on other sites More sharing options...
AV1611 Posted September 23, 2007 Share Posted September 23, 2007 I've never actually tried to do it, but one way is to connect to the main (left) one then parse in the second (right) one within the results. but I *think* you can just open both and use the database.table.field but I'm not sure Quote Link to comment https://forums.phpfreaks.com/topic/70362-id-of-one-table-pulling-the-id-of-another/#findComment-353463 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.