lional Posted December 2, 2006 Share Posted December 2, 2006 Is it possible to do a join on more than one table eg$query = "SELECT * from personal_details JOIN ra_card_1 ON personal_details.member_no = ra_card_1.member_no AND form1.form1 ON personal_details.member_no = form.member_no WHERE form1.chapter_no = '$chapnum AND form1.form1 = 0'";What I am trying to do is to select the member from personal_details table where that member is a member of a specific chapter that is specified in ra_card_1 table, but I also want to check if they have submitted their information and that is stored in the form1 tableIs this possible and if it is, please give me some pointers on how to do itThanksLional Quote Link to comment Share on other sites More sharing options...
artacus Posted December 2, 2006 Share Posted December 2, 2006 You need a JOIN ON statement for every table except the first. Also, I couldn't tell from your example where form1 fit in so you'll have to use my example to work it in.[code]SELECT * FROM personal_details AS pdJOIN ra_card_1 AS card ON personal_details.member_no = ra_card_1.member_no JOIN form AS f ON pd.member_no = f.member_no JOIN form1 AS f1 ON (this should tie back to the pd or form table but I dont know how)WHERE form1.chapter_no = '$chapnum AND form1.form1 = 0'[/code](technically, MySQL will allow you to declare multiple tables in the FROM statement but it will choke when you try to add joins on anything but the last table defined in the FROM clause) Quote Link to comment 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.