Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

wwwxxxAPC, How to unsubscrube from dategen spam, WWWXXXAPC, docmd.close 2585, WWWXXXDOCO, nu vot, dhcpd lease file "binding state", WWWXXXDOCO, how to setup procmail to process html2text, how to setup procmail html2text

Links

XODOX
Impressum

#1: inserting unique value

Posted on 2007-06-21 15:20:20 by Rune Zedeler

I need to insert a unique value into a (not auto-increment) column.
I try

insert into idtest (val) values ((select max(val) from idtest)+1);

but I get

ERROR 1093 (HY000): You can't specify target table 'idtest' for update
in FROM clause

- what is the correct way to do this?

Regards,
Rune

Report this message

#2: Re: inserting unique value

Posted on 2007-06-22 16:42:05 by Shawn Hamzee

== Quote from Rune Zedeler (rz@daimi.au.dk)'s article
> I need to insert a unique value into a (not auto-increment) column.
> I try
> insert into idtest (val) values ((select max(val) from idtest)+1);
> but I get
> ERROR 1093 (HY000): You can't specify target table 'idtest' for update
> in FROM clause
> - what is the correct way to do this?
> Regards,
> Rune

how about this:

insert into idtest (val) (select (max(val)+1) from idtest);

let me know if it works for you.
--
POST BY: lark with PHP News Reader

Report this message

#3: Re: inserting unique value

Posted on 2007-06-22 18:24:30 by Rune Zedeler

lark skrev:

> insert into idtest (val) (select (max(val)+1) from idtest);

Thanks, works! :+)

-Rune

Report this message