mp3lab Posted March 24, 2012 Share Posted March 24, 2012 Hi As I'm new to PHP/MySQL I need a little help concerning joining 4 tables in SQL query. I have 4 tables first is asort with 4+ columns id catid pid tipid ... id is primary key and catid, pid and tipid are foreign keys from tables kategorija, proizvod and tip I want to make a query to join this 4 tables and find for example all rows with pid=4 I tryed with $q1 = "SELECT * FROM asort LEFT JOIN (kategorija, proizvod, tip) ON (kategorija.catid=asort.catid AND proizvod.pid=asort.pid AND tip.tipid=asort.tipid) where tipid='$_GET[tipid]' order by cijena asc"; but I got "Column 'tipid' in where clause is ambiguous" Thank you for reading this especially if you are able to help me out on this. Bye DVAL Quote Link to comment https://forums.phpfreaks.com/topic/259657-joining-tables-help-needed-please/ Share on other sites More sharing options...
trq Posted March 24, 2012 Share Posted March 24, 2012 As tipid is defined within several tables you need to tell mysql which one you wish to use in your where clause. Quote Link to comment https://forums.phpfreaks.com/topic/259657-joining-tables-help-needed-please/#findComment-1330825 Share on other sites More sharing options...
mp3lab Posted March 25, 2012 Author Share Posted March 25, 2012 thank you for your respond I put where asort.tipid='$_GET[tipid]' order by cijena asc and it works fine Quote Link to comment https://forums.phpfreaks.com/topic/259657-joining-tables-help-needed-please/#findComment-1330878 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.