mikew101 Posted June 27, 2007 Share Posted June 27, 2007 Hello. I using the following select statement to send to mysql. "SELECT * FROM table WHERE name LIKE '%$search%' OR desci LIKE '%$search%' AND price < 20" The price fields actually have the dollar sign before a price. So for instance each value will like "$4.99" or "$34.99", and so on according to their indivdual prices. The above select cannot work due to mysql not being able to understand that the prices are number due to the dollar sign included. Is their anyway to get the value of the numbers within the mysql statement? I am trying to seperate results based on user input to change results for price. Any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/57349-solved-value-of-price-within-mysql/ Share on other sites More sharing options...
AndyB Posted June 27, 2007 Share Posted June 27, 2007 You could try ... and price <'$20.00' You can't compare a number and a string because strings have a numerical value of zero. Personally, I'd drop the $ from the database and add it when I displayed results. If price is numeric you can do any kind of math you want with it. As a string, it's kind of useless. Quote Link to comment https://forums.phpfreaks.com/topic/57349-solved-value-of-price-within-mysql/#findComment-283679 Share on other sites More sharing options...
bubblegum.anarchy Posted June 27, 2007 Share Posted June 27, 2007 SELECT * FROM table WHERE ( name LIKE '%$search%' OR desci LIKE '%$search%' ) AND trim('$' FROM price) < 20 Quote Link to comment https://forums.phpfreaks.com/topic/57349-solved-value-of-price-within-mysql/#findComment-283788 Share on other sites More sharing options...
mikew101 Posted June 27, 2007 Author Share Posted June 27, 2007 bubblegum.anarchy Hey thanks! At first I could not get it to work, but after I put that first set of () it worked great. -Mike Quote Link to comment https://forums.phpfreaks.com/topic/57349-solved-value-of-price-within-mysql/#findComment-284286 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.