digitalgod Posted July 11, 2007 Share Posted July 11, 2007 hey guys, I'm having problems using INNER JOIN was just wondering if someone could give me a hand. I have 2 tables, productsaffiliates and affiliates , I need to query the first table and be able to display it's info plus the info of the affiliate that's attached to that table... so productsaffiliates looks like this +-----------+--------------+------------+--------+----------+---------+ | id | productid | affiliateid | mysite | unitcost | unitprice | +-----------+--------------+------------+--------+----------+---------+ | 1 | 1 | 1 | 0 | 160 | 180 | +-----------+--------------+------------+--------+----------+---------+ and affiliates looks like this +-----------+--------------+------------+-----------+------------+ | id | username | password | firstname | lastname | +-----------+--------------+------------+-----------+------------+ | 1 | test | test123 | John | Smith | +-----------+--------------+------------+-----------+------------+ so when I do SELECT DISTINCT productsaffiliates.id, productid, affiliateid, unitcost, unitprice, mysite FROM productsaffiliates INNER JOIN affiliates ON productsaffiliates.affiliateid = affiliates.id WHERE productsaffiliates.productid =1 if I echo $prereq["firstname"] I get an undefined index but if I echo $prereq["unitcost"] I do get the 160 what am I doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/59497-solved-help-with-inner-join/ Share on other sites More sharing options...
digitalgod Posted July 11, 2007 Author Share Posted July 11, 2007 sorry my stupid mistake, forgot to select those fields.... I'm too tired I guess hehe Quote Link to comment https://forums.phpfreaks.com/topic/59497-solved-help-with-inner-join/#findComment-295686 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.