I want a MySQL query that will display all the real estate properties with 3 bedrooms, 2 baths, and are either houses or duplexes. Here's my query:
$row=mysql_query('SELECT * FROM props WHERE bed="3" AND bath="2" AND type="house" OR type="duplex"');
But it obviously doesn't work. How can I get this working?
MySQL query with AND, OR statements [SOLVED]
Moderator: General Moderators
MySQL query with AND, OR statements [SOLVED]
Last edited by amh1010 on Mon Mar 01, 2010 8:54 am, edited 1 time in total.
Re: MySQL query with AND, OR statements
Code: Select all
$row=mysql_query("SELECT * FROM props WHERE bed='3' AND bath='2' AND (type='house' OR type='duplex')");All rows where bed=3, bath=2 and type=house
OR all rows where type=duplex
Putting the type into brackets will return only rows where bed=3 and bath=2 and the type is either house or duplex.
HTH.
Cheers,
Dave.
Re: MySQL query with AND, OR statements
Works perfectly. Thanks