yandoos Posted July 17, 2015 Share Posted July 17, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/297338-join-4-tables/ Share on other sites More sharing options...
fastsol Posted July 17, 2015 Share Posted July 17, 2015 That's a permissions issue on the table itself, not the query or coding at this point. The table is denying you from using SELECT on it. Quote Link to comment https://forums.phpfreaks.com/topic/297338-join-4-tables/#findComment-1516630 Share on other sites More sharing options...
yandoos Posted July 17, 2015 Author Share Posted July 17, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/297338-join-4-tables/#findComment-1516634 Share on other sites More sharing options...
Solution Barand Posted July 17, 2015 Solution Share Posted July 17, 2015 (edited) Try ... LEFT JOIN sold ON distribution.pdid = sold.pdid Edited July 17, 2015 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/297338-join-4-tables/#findComment-1516636 Share on other sites More sharing options...
yandoos Posted July 17, 2015 Author Share Posted July 17, 2015 Thank you Quote Link to comment https://forums.phpfreaks.com/topic/297338-join-4-tables/#findComment-1516637 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.