Jump to content

Join 4 tables


yandoos
Go to solution Solved by Barand,

Recommended Posts

Hello i was hoping for some help please. I have a select that joins 3 tables together (plus_signup, product and distribution) but I need to join another table to it (sold). Every time I try it out in phpmysql I get an error - SELECT command denied to user 'name'@'localhost' for table 'pdid'.

 

The tables are:

 

plus_signup

[mem_id]

userid

user_level

password

 

product

[pid]

productname

description

price

 

distribution

[pdid]

pid*

mem_id*

status

start

end

 

sold

[sid]

pdid*

qty

ref

confirmed

date

 

Here is the working SELECT for the 3 tables

SELECT * FROM distribution join product ON distribution.pid = product.pid
                                  join plus_signup ON distribution.mem_id = plus_signup.mem_id
					WHERE distribution.mem_id = '4'

Here is what I have tried when adding the fourth table (sold) to it

SELECT * FROM distribution join product ON distribution.pid = product.pid
                                  join plus_signup ON distribution.mem_id = plus_signup.mem_id
				  join sold.pdid ON distribution.pdid = sold.pdid
					WHERE distribution.mem_id = '4'

It's just not working so I'm wondering how to fix it and whats wrong?

Can you help me please?

 

Thank you

Link to comment
Share on other sites

I made a mistake and needed to remove the .pdid from

 

join sold.pdid ON distribution.pdid = sold.pdid

 

I think perhaps I have the wrong type of join because it is not pulling out all the data in that it pulls the amount of record that are in the sold table. Is there a different join I can use in this scenario?

 

Thank you
             

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.