Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
Correctly using '<=' in a query
Old 08-17-2005, 05:50 AM Correctly using '<=' in a query
Experienced Talker

Posts: 36
Trades: 0
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:

Nationality:British
Sex:Male
Prefecture:Tokyo
Price:3000

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:


Code:
$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:
AND
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"] . "

Quote:
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..
jool is offline
View Public Profile
 
 
Register now for full access!
Old 08-17-2005, 07:44 AM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
Isn't this a duplicate post of thread http://webmaster-talk.com/showthread.php?t=34313?
__________________
—Kyrnt
Kyrnt is offline
View Public Profile Visit Kyrnt's homepage!
 
Closed Thread     « Reply to Correctly using '<=' in a query
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19283 seconds with 12 queries