Jump to content

[SOLVED] Correct syntax to join 3 tables


poleposters

Recommended Posts

Hi

 

I have three tables. One has the user information, one their address and the other some listing information.

 

I want to join them. I tried doing something similar to joining 2 tables but thats not working. Can anyone tell me what I'm doing wrong?

 

 $selectlinks="SELECT * from coupon,users,address  WHERE coupon.business_id=users.business_id=address.business_id AND postcode like '%$searchterm' and cat_id=$catid or coupon.business_id=users.business_id=address.business_id AND suburb like '%$searchterm' and cat_id=$catid order by paid_listing DESC limit $start,$numentries";

Link to comment
https://forums.phpfreaks.com/topic/100632-solved-correct-syntax-to-join-3-tables/
Share on other sites

Great!

 

Except now I'm running into some trouble with a similar query.

 

$selectlinks="SELECT * FROM coupon LEFT JOIN users ON coupon.business_id=users.business_id LEFT JOIN address  ON users.business_id=address.business_id  WHERE business_id=$businessid order by date_added DESC limit $start,$numentries";

 

I get this message

 

Column 'business_id' in where clause is ambiguous

 

 

Archived

This topic is now archived and is closed to further replies.

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