Jump to content

Use two "BETWEEN" in one query


AGazzaz

Recommended Posts

Hello,I want to enable the user to search by both price and area in the same time by entering price and area rangesuntil now I can search any of those two using "between" but I can not use 2 "between" in one queryIs that possible?If it is not What is the alternative?Thank you in advance

Link to comment
Share on other sites

You might need to add parens for clarity.

$result = mysql_query("SELECT * FROM price WHERE (price BETWEEN $price1 AND $price2) AND (area BETWEEN $area1 AND $area2)") or die(mysql_error());

There might also be an issue because you named a field the same thing as the table.

Link to comment
Share on other sites

I found what was the problem, it was not the syntax of the query or the name of the table the whole problem was that I wrote$area2 = floatval($_post['area2'];instead of:$area2 = floatval($_POST['area2'];thank you very much for your help justsomeguy, You are the BEST!!!.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...