Reputation: 137
Heres the query I am using:
SELECT * FROM inventory WHERE status='live' and price<='50' ORDER BY id DESC;
It is showing all items under $50. But then it also shows all items over $100? I'm guessing this issue has something to do with these prices being triple digits. Other thing to mention is that the prices also include .00 after their price.
Any pointers?
Upvotes: 0
Views: 4080
Reputation: 3286
I think the problem is that you have 50 in quotes. MySql is probably treating it like a string.
... AND price <= 50 ORDER BY ....
Upvotes: 1
Reputation: 616
If the price column datatype is "CHAR" (string), "100", and "49999" are both <= "50". Change one or both data types (columns and comparison) to DECIMAL(10,2) or another numeric type.
Upvotes: 0