Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.