Jump to content

[SOLVED] help with INNER JOIN


digitalgod

Recommended Posts

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?

 

Link to comment
https://forums.phpfreaks.com/topic/59497-solved-help-with-inner-join/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.