mysql - SQL Query to insert into a particular column from output of select query -


i have query shown below:

select department departmentname,count(distinct(uid)) userscnt  outlier_report department not null group department ; 

i want insert outlier_output table populated , has 20 fields including departmentname , user_count (this field empty). want put userscnt field output of select outlier_output table department=outlier_report.departmentment_name

i assuming this:

insert outlier_output(user_count select department, count(distinct(uid) userscnt outlier_report department=outlier_report.departmentment_name) 

how exact query be? in advance

standard insert-select format is:

insert `tablea` ([field_list]) select [results corresponding items in field list in same order field list] [etc...] 

http://dev.mysql.com/doc/refman/5.6/en/insert.html


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -