How can I use count condition in sql query. Here is my query
SELECT COUNT(test='maths') FROM homework where id = 1;
In MySQL conditions have either 1 or 0 as outcome. So use sum() instead
SELECT sum(test='maths') FROM homework where id = 1;
count() just counts non-null values. So you could do it with count() too but like this
SELECT count(case when test='maths' then 1 else null end)
FROM homework
where id = 1;