要求更改查询到的第一个满足tag=0条件的改为tag=1
就是这个意思,下面是错的
update table1  set tag=1 where id=(select id from table1 where tag=0 limit 0,1);

解决方案 »

  1.   

    update table1  set tag=1 where id in(select id from table1 where tag=0 limit 0,1)
      

  2.   

    update table1 a, (select id table1 where tag=0 limit 0,1) b
    set a.tag=1
    where a.id=b.id
      

  3.   

    少写了个 from
    update t_qqwx_1986 a, (select id from t_qqwx_1986 where tag=0 limit 0,1) b
    set a.tag=1
    where a.id=b.id测试如下.mysql> select * from t_qqwx_1986;
    +----+------+
    | id | tag  |
    +----+------+
    |  1 |    1 |
    |  2 |    0 |
    |  3 |    0 |
    |  4 |    1 |
    +----+------+
    4 rows in set (0.00 sec)mysql> update t_qqwx_1986 a, (select id from t_qqwx_1986 where tag=0 limit 0,1) b
        -> set a.tag=1
        -> where a.id=b.id;
    Query OK, 1 row affected (0.03 sec)
    Rows matched: 1  Changed: 1  Warnings: 0mysql> select * from t_qqwx_1986;
    +----+------+
    | id | tag  |
    +----+------+
    |  1 |    1 |
    |  2 |    1 |
    |  3 |    0 |
    |  4 |    1 |
    +----+------+
    4 rows in set (0.00 sec)mysql>
      

  4.   

    谢了(select id from t_qqwx_1986 where tag=0 limit 0,1) b  这个地方有点不明白什么意思,能说明下最好了
      

  5.   

    select id from t_qqwx_1986 where tag=0 limit 0,1 这一句明白吗?(select id from t_qqwx_1986 where tag=0 limit 0,1) b  只是定义了个子查询,