2012-10-25 70 views

回答

2

沒有, 你會正是這樣一個

INSERT INTO mydb.table (field) 
SELECT Count(*) 
FROM sometable 
WHERE points=30; 

與多個列

INSERT INTO mydb.table (Col1, Col2, Col3) 
SELECT Col1, Col2, Count(*) 
FROM sometable 
WHERE points=30; 

Here另一個例子,你可以找到很多例子。

+1

大聲笑,我知道,我做了這樣的權利我張貼了這個愚蠢的問題....之後' SET @ S ='更新'games' \t \t \t \t SET? =(SELECT COUNT(*) \t \t \t \t \t \t FROM'cards' \t \t \t \t \t \t WHERE?=?) \t \t \t \t WHERE'gamenumber' =(SELECT'gameNumber' \t \t \t \t \t \t \t \t \t \t \t FROM'cards'?\t \t \t \t \t \t \t \t \t \t \t WHERE'UUID' =)'; \t \t準備從@s; \t \t EXECUTE stmt USING @ v6,@ v4,@ v3,@ v1; \t \t DEALLOCATE PREPARE stmt;' 謝謝你麻煩回答THO :) –

1
INSERT INTO myTable (field) VALUES 
(SELECT COUNT(*) FROM sometable where points=30) 
相關問題