jaylam13 Posted September 20, 2011 Share Posted September 20, 2011 Hi, Can anyone help please, I want to reference a field from one database to another. So I have two databases: db1 has tables called ID and Name db2 has tables called ID and Stock In db1 the ID field is a number and the name is the Name of that item. In db2 the fields are populated by people selecting items from a drop down list box which is populated via db1. The ID field in db2 is just a auto incremented number and the Stock becomes the ID of what every they have selected from the drop downlist box populated by db1. This works but when the user views his stock obviously it just shows a number what I would like the query to do is grab Stock value from db2, look that up in db1 as it will match a ID then use the Name for the item from db1. I hope this makes sense, is it possible if so how do I go about it.....im confused. Thanks in advance Jay Link to comment https://forums.phpfreaks.com/topic/247497-query-help-2-databases/ Share on other sites More sharing options...
AyKay47 Posted September 20, 2011 Share Posted September 20, 2011 look into using a Union Link to comment https://forums.phpfreaks.com/topic/247497-query-help-2-databases/#findComment-1270944 Share on other sites More sharing options...
mikosiko Posted September 20, 2011 Share Posted September 20, 2011 look into using a Union sure you tried to say JOIN instead of UNION right? Link to comment https://forums.phpfreaks.com/topic/247497-query-help-2-databases/#findComment-1270976 Share on other sites More sharing options...
AyKay47 Posted September 20, 2011 Share Posted September 20, 2011 look into using a Union sure you tried to say JOIN instead of UNION right? well since both tables have the same number of columns here.. a UNION will work. unless im misunderstanding the OP Link to comment https://forums.phpfreaks.com/topic/247497-query-help-2-databases/#findComment-1270983 Share on other sites More sharing options...
mikosiko Posted September 20, 2011 Share Posted September 20, 2011 This works but when the user views his stock obviously it just shows a number what I would like the query to do is grab Stock value from db2, look that up in db1 as it will match a ID then use the Name for the item from db1. well since both tables have the same number of columns here.. a UNION will work. unless im misunderstanding the OP well... seems to me that you did Link to comment https://forums.phpfreaks.com/topic/247497-query-help-2-databases/#findComment-1270991 Share on other sites More sharing options...
AyKay47 Posted September 20, 2011 Share Posted September 20, 2011 This works but when the user views his stock obviously it just shows a number what I would like the query to do is grab Stock value from db2, look that up in db1 as it will match a ID then use the Name for the item from db1. well since both tables have the same number of columns here.. a UNION will work. unless im misunderstanding the OP well... seems to me that you did yep i did.. JOIN Link to comment https://forums.phpfreaks.com/topic/247497-query-help-2-databases/#findComment-1270997 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.