Jump to content

[SOLVED] value of price within mysql


mikew101

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/57349-solved-value-of-price-within-mysql/
Share on other sites

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.

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.