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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.