mysql - How to fetch data from two db and insert into temp table, using SQL? -


i have 2 databases old , new. want count record both databases , insert new temporary table table name.

i created temporary table:

create temporary table tempemp (tablename varchar(50),northwindcount int(11),dest_northwindcount int(11)); 

and counted records:

select (select count(*) northwind.orders) northwind_cnt, (select count(*) dest_northwind.orders) dest_northwind_cnt; 

how can insert temp table?

dunno mysql, in ms sqlserver t-sql, you'd this:

insert     tempemp(        tablename,northwindcount,dest_northwindcount) select      '???' table make,         (select count(*) northwind.orders)        northwindcount,     (select count(*) dest_northwind.orders)          dest_northwindcount 

my syntax might little off, general idea insert statement can have select clause instead of values clause. maybe similar in mysql?


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -