Santosh Pillai
Santosh Pillai

Reputation: 1391

mysql insert into table from multiple select queries

How do i combine this into a single insert

INSERT INTO masterTable (count1) select count(*) as count1 from tablex
INSERT INTO masterTable (count2) select count(*) as count2 from tabley
INSERT INTO masterTable (count3) select count(*) as count3 from tablez

Upvotes: 0

Views: 36

Answers (1)

Rodrigo Murillo
Rodrigo Murillo

Reputation: 13648

INSERT INTO MasterTable (count1,count2,count3) 
VALUES ((select count(*) from tablex),(select count(*) from tabley),(select count(*) from tablez))

Upvotes: 1

Related Questions