Jump to content

joins


An7hony

Recommended Posts

Hi i am trying to do a join between 2 tables but it is pulling duplicate results.

 

i.e:

 

$query = "SELECT norton_rent.id, norton_rent.Prop_DisplayAddress, norton_rent.Prop_DisplayAddress, norton_rent.Prop_PropType, norton_rent.Prop_Price, norton_rent.Prop_Bedrooms, norton_rent.Prop_Description, norton_rent.Prop_VebraID,  norton_rent_img.File_url, norton_rent_img.Prop_VebraID, norton_rent_img.File_index FROM norton_rent LEFT JOIN norton_rent_img ON (norton_rent.Prop_VebraID = norton_rent_img.Prop_VebraID) WHERE norton_rent.Prop_Bedrooms LIKE '%".$_GET['beds']."%' AND norton_rent.Prop_Price < '".$_GET['maxsaleprice']."' AND norton_rent.Prop_VebraID=norton_rent_img.Prop_VebraID AND norton_rent_img.File_index=0 LIMIT ".$offset.", ".$per_page."";
			$result = mysql_query($query) or die(mysql_error());

 

Its ok if i take out

WHERE norton_rent.Prop_Bedrooms LIKE '%".$_GET['beds']."%' AND norton_rent.Prop_Price < '".$_GET['maxsaleprice']."' 

 

just wondered if anyone can see why?

 

thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/225485-joins/
Share on other sites

Hi

 

I would expect each property to have multiple images, and so expect the same property to be brought back multiple times, once for each image.

 

However I can't see anything obvious that would bring back unwanted duplicates.

 

Only odd thing is that you have the JOIN match up in both the ON clause and the WHERE clause.

 

All the best

 

Keith

Link to comment
https://forums.phpfreaks.com/topic/225485-joins/#findComment-1164390
Share on other sites

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.