MYSQL Loop variable inside query
<p>I have a list of IDs that I want to Loop through the query below. So I want the query to run for each ID and have ID_FROM_LIST pull the next ID out of LIST_OF_IDS. </p>

<p>List:</p>

<pre><code>LIST_OF_IDS = (379, 517, 519, 797, 800, 896, 897, 900, 902, 903, 904, 905, 906, 907, 919)
</code></pre>

<p>Query:</p>

<pre><code>    select w.Record_Count, w.Distinct_Provider_Count from  
(select  c as Record_Count, dc as Distinct_Provider_Count
from
(select * from centene_cic_decodes where standard_use in ('','P','PL')) r left join
(
select 
deceased_status as t, count(*) as c , count(distinct group_key) as dc,  'provider_status' as cat
from t_conditioncodes_0086252_cen_idvf2 
where NET_ID_ef = ID_FROM_LIST
group by 1 
union all 
select 
name_status  as t, count(*) as c , count(distinct group_key) as dc,  'name_status' as cat
from t_conditioncodes_0086252_cen_idvf2  
where NET_ID_ef = ID_FROM_LIST
group by 1
) z
on (if((z.t is null or z.t = ''), 'BLANK',z.t)) = r.Status_Codes and z.cat = r.Category 
order by r.category_rank, r.rank)w ;
</code></pre>

<p>The goal is to create a separate output for each ID. So one report for 379 then a separate one for 517 etc... </p>

<p>(This is just a snippet of the full query and list of IDs for simplicity.)</p>