467,080 Members | 987 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,080 developers. It's quick & easy.

inserting unique value

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
Jun 21 '07 #1
  • viewed: 2685
Share:
2 Replies
== 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
Jun 22 '07 #2
lark skrev:
insert into idtest (val) (select (max(val)+1) from idtest);
Thanks, works! :+)

-Rune
Jun 22 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by luc wastiaux | last post: by
2 posts views Thread by kevin parks | last post: by
3 posts views Thread by Joachim Klassen | last post: by
6 posts views Thread by planetthoughtful | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.