Hi,
Olav Mørkrid wrote:
mysql> update test set id = (select max(id) + 1 from test) where id =
'$myid';
ERROR 1093 (HY000): You can't specify target table 'test' for update
in FROM clause
You will need to place the subquery in another subquery in the FROM clause so it is
materialized to a temorary table:
update test set id = (
select id + 1 from ( select max(id) as id from test ) as x
)
where id = $myid;
If you need to do this kind of query on insert, there are other things to think about
too. See http://www.xaprb.com/blog/2006/04/20/sequences-and-surrogate-keys-in-generic-sql/
Baron
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]