update的 update table_name set id=4 ,name='dadw' ,price=77 ,descp='cc' where id=select id from table_name where name='dadw';
id 是要通过后面一个select语句得到..是否语句写错了..都来赐教哦!!!!

解决方案 »

  1.   

    update table_name set id=4 ,name='dadw' ,price=77 ,descp='cc' where id in (select id from table_name where name='dadw');看看
    select id from table_name where name='dadw'是否不只一条记录
      

  2.   

    In general, you cannot modify a table and select from the same table in a subquery. For example, this limitation applies to statements of the following forms: DELETE FROM t WHERE ... (SELECT ... FROM t ...);
    UPDATE t ... WHERE col = (SELECT ... FROM t ...);
    {INSERT|REPLACE} INTO t (SELECT ... FROM t ...);Exception: The preceding prohibition does not apply if you are using a subquery for the modified table in the FROM clause. Example: UPDATE t ... WHERE col = (SELECT ...from (SELECT ... FROM t...) AS _t ...);
      

  3.   

    yangxiao_jiang(哈哈)  你说的我也试过..
    出这样的错误 You can't specify target table 'table_name' for update in FROM clause
      

  4.   

    update table_name set id=4 ,name='dadw' ,price=77 ,descp='cc' where id=
    (select A.id from (select id,name from table_name) AS A where A.name='dadw');
      

  5.   

    update table_name set id=4 ,name='dadw' ,price=77 ,descp='cc' where id=(select top 1 id from table_name where name='dadw');
      

  6.   

    此语句可行.顺便问个问题.如果要修改表里的所有字段,where 以谁做条件呢,
      

  7.   

    tt2451的语句可行.顺便问个问题.如果要修改表里的所有字段,where  以谁做条件呢,