A have a column named key - 1,1,2,2,2,2,3 Now i do it with 3 querys:
SELECT count(key) as k FROM `test` WHERE key=1
SELECT count(key) as k FROM `test` WHERE key=2
SELECT count(key) as k FROM `test` WHERE key=3
How to count in one query how many 1,2,3?
Use group by:
SELECT `key`, COUNT(*) FROM `test` GROUP BY `key`;
you can do like this
select count(key) as K FROM test where key in (1,2,3)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With