Fireflies :
When I run a mySQL query:
SELECT * FROM jobs WHERE salary >= '50000';
It returns all the jobs which salaries are over 50000. However, there is two jobs, which have salaries of 8 and 9 and they are returned too. In fact, all jobs, which have salaries between 10 and 5 are returned. (For example, salaries which are 2 are not returned). It's pretty weird and I am not sure what is causing this error.
Gordon Linoff :
Presumably, salary
is stored as a string, but you want it ordered as a number.
If salary
were a number, then the comparison would implicitly convert it. Instead, be explicit:
WHERE salary + 0 >= 50000;
Then, fix the data. Something like:
alter table jobs
modify column salary decimal(20, 4);