Mysql query matches multiple values in a single field

The

table is roughly as follows:
id sample
1 a
2 b
3 a
4 c
5 d
6 c

Select the count of the sample grouping of id=3,4 (specified field)

   select count(sample) from table where id=3 or id=4 group by sample

the current problem is that if you want to query too many id values, the query statement will be very long, and if the table is large, the rate will be very slow. I would like to ask if there is a better operation. Thank you

.
Apr.11,2021

For continuous cases, use BETWEEN , such as

SELECT COUNT(sample) FROM table WHERE id IN (<id>) GROUP BY sample
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b384ca-e651.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b384ca-e651.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?