What is the different in these two? How come I’m getting a different answer?
select count(salary >= ‘100000’) from salaries;
select count(*) from salaries
where salary >=’100000′ ;
Thanks for reaching out!
You are getting a different answer because of the rules set by the MySQL syntax, so to speak. Therefore, there’s not too much logic to look for here – there are rules to learn and stick to.
The first query you have isn’t really complying with the MySQL syntax, because this is not the way to specify a condition. The way to do that is, as you’ve done in the second query, with the help of a WHERE clause.
Hope this helps.