2016-01-22 39 views
0

表如何合併到這個單個插入MySQL的INSERT INTO從多個選擇查詢

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 

回答

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

我已經發布前試過了,同樣的,但看到語法錯誤 –

+0

對不起,我已經改正了。 –

+0

謝謝。現在起作用 –