View Full Version : How to use <= in a submit query

08-17-2005, 09:53 AM
Hello all.

I have a search form which I'd like to return values based on values entered. Until now I had been returning results based on values equal to those entered. Basically if the values in the search form entered were:


All results returned from the search would be British males from Tokyo whose price is 3000.

However I wished to change the query so that results returned would include values less than or equal to the price entered.

My original query was as follows:

$query_m = "SELECT TestTable.autonumber, TestTable.sex, TestTable.firstname, TestTable.nationality, TestTable.private_price FROM TestTable WHERE TestTable.language LIKE '%" . $_REQUEST["language"] . "%' AND TestTable.prefecture LIKE '%" . $_REQUEST["prefecture"] . "%' AND TestTable.sex LIKE '%" . $_REQUEST["sex"] . "%'AND TestTable.nationality LIKE '%" . $_REQUEST["nationality"] . "%' ....more of the same... AND TestTable.sue LIKE '%" . $_REQUEST["sue"] . "%' AND TestTable.private_price LIKE '%" . $_REQUEST["private_price"] . "%'";
in particular note:
TestTable.private_price LIKE '%" . $_REQUEST["private_price"] . "%'";

This returned all values with as expected.
However, I tried replacing this private price to include equal to or less than values, but had no success. I tried the following (in place of the above):

TestTable.private_price <= .'$_REQUEST["private_price"] . '

TestTable.private_price =< .'$_REQUEST["private_price"] . '

TestTable.private_price =< " . $_REQUEST["private_price"] . "

ERROR (You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '=< 1000' at line 2)

TestTable.private_price <= '%" . $_REQUEST["private_price"] . "%'

TestTable.private_price <= $_REQUEST["private_price"]

These all returned errors....

The datatype was varchar but I had changed it to decimal(12,0)

Can anyone help???

Thanks for reading this post - your effort is appreciated..

08-17-2005, 02:01 PM
Ah...it seems

TestTable.private_price <= " . $_REQUEST["private_price"] . "


Thanks :D