How to insert a record for each result in a mySQL query? -


hello call mysql query select in console (or in phpmyadmin sql cmd)

select hf, id ah hf !=0 group hf; 

after need execute command each returned line previous select

foreach   if (select count(*) `tot` `id` = @selectedid , `uto` = @selectedhf ) = 0           insert `tot` (`id`, `hf`) values (@selectedid, @selectedhf);   end if; endforeach; 

how can "foreach" loop in mysql?

you can single query, insert . . . select. no need loop, want check non-existence:

insert `tot` (`id`, `hf`)      select id, hf     ah     hf <> 0 ,            not exists (select 1 tot tot.id = a.id , tot.uto = @selectedhf)     group hf; 

Comments

Popular posts from this blog

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -

How to run C# code using mono without Xamarin in Android? -