Jump to content

LEFT JOIN with multiple WHERE statements


Odaku128

Recommended Posts

Hello there,

 

Im having a problem with the following sql statement.

 

SELECT * FROM property_list LEFT JOIN photo_list ON property_list.Property_ID = photo_list.Property_ID WHERE Main_Pic = '1'

 

The above statement works. It retrieves a property and only the main picture of that property.

 

I want to add another WHERE statement to select a property by its id, so it looks something like this.

 

SELECT * FROM property_list LEFT JOIN photo_list ON property_list.Property_ID = photo_list.Property_ID WHERE Main_Pic = '1' AND Property_ID = $propertyid

 

What is the correct way to go about doing this?

 

Thanks in advance.

 

Phil

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.