2011-05-05 71 views
1

我運行下面的查詢在MySQL限制MySQL的REPEAT

REPEAT 
    INSERT IGNORE INTO tableB 
     SELECT a.column_name, a.level+1 
     FROM tableA AS a 
    UNTIL Row_Count() = 0 END REPEAT; 

,但我想提出一個限制它,使它停止重複,如果a.level得到上述10(或ROW_COUNT()= 0 )。我將如何做到這一點?

+0

沒有遞歸。 – Emmerman 2011-05-05 09:00:59

+0

@Emmerman我改變了措辭並刪除了遞歸 – John 2011-05-05 09:10:50

回答

1
REPEAT 
    INSERT IGNORE INTO tableB 
     SELECT a.column_name, a.level+1 
     FROM tableA AS a 
     WHERE a.level <= 10 
    UNTIL Row_Count() = 0 END REPEAT; 

或者我不明白。