日期:2014-05-16  浏览次数:20664 次

Mysql中写循环SQL语句
我有想给 id(471-541)中的没一个用户增加一条相同数据,请问mysql中怎么写这个循环语句

------解决方案--------------------
id(471-541)中的没一个用户增加一条相同数据:举例说明
------解决方案--------------------
SQL code
CREATE TEMPORARY TABLE seqnumber
(
  id int not null auto_increment primary key,
  flag bit
) auto_increment=471 ENGINE=MEMORY;

INSERT INTO seqnumber(flag)
    SELECT 0 FROM information_schemas.COLUMNS LIMIT 70;

CREATE TEMPORARY TABLE tmp_tb ENGINE=MEMORY
AS
    SELECT
        A.id,'username' AS username
    FROM seqnumber AS A
        LEFT JOIN tb AS B
           ON A.id=B.id
    WHERE B.id IS NULL;

INSERT tb(id,username) SELECT * FROM tmp_tb;