How does mysql query their respective sum ('number') based on the Id array at once?

now there is an array. You need to find out the sum of the fields number when the field card_id equals each value of the array
. Finally, you want the result to look something like this:
card_id sum
1 10
2 20

.

currently, you can only traverse queries one by one, and you need to query the database many times: $this- > model- > where ("card_id", $id)-> sum (" number");
I don"t know if there is any way to query all at once

.
Jun.11,2021

select card_id,sum (number) from tablename where card_id in array_cardid group by card_id;


where id in (1 Magazine 2) get to know

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-1b37a23-3445c.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-1b37a23-3445c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?