I'm new at SQL and one thing that I've just learned reading other posts is that there are no FOR loop constructs in SQL and it is not a good practice trying emulate it somehow.
Anyhow, I've got this problem that I would approach iteratively: a table has 2 columns,
select count(id) from favorite_retails
where retail_id = 42
You would use
group by, if you want the answer for each one:
select retail_id, count(id) from favorite_retails where retail_id in ( 31, 54, 98 ) group by retail_id;
where if you want the answer for all