表示你使用了像下列的語法:
CREATE TEMPORARY TABLE tempTable
SELECT * FROM tableA
INSERT INTO tempTable
SELECT * FROM tableB
WHERE tableB.`cname` IN (SELECT `cname` FROM tempTable);
MySQL中,是不允許一段語法裡,做出像是遞迴的動作的語法,其他資料庫我沒試過,所以不知道可不可以這樣做,而會出現這種錯誤,通常都是因為疏忽(就是在說我自已…= =),建議解決方式:再用一個暫存Table來存原本暫存Table的值,如下:SELECT * FROM tableA
INSERT INTO tempTable
SELECT * FROM tableB
WHERE tableB.`cname` IN (SELECT `cname` FROM tempTable);
CREATE TEMPORARY TABLE tempTable
SELECT * FROM tableA
CREATE TEMPORARY TABLE tempTable2
SELECT * FROM tempTable
INSERT INTO tempTable
SELECT * FROM tableB
WHERE tableB.`cname` IN (SELECT `cname` FROM tempTable2);
SELECT * FROM tableA
CREATE TEMPORARY TABLE tempTable2
SELECT * FROM tempTable
INSERT INTO tempTable
SELECT * FROM tableB
WHERE tableB.`cname` IN (SELECT `cname` FROM tempTable2);
沒有留言:
張貼留言