Re: can a subquery be used in an insert

2005-01-20 Thread SGreen
James Black <[EMAIL PROTECTED]> wrote on 01/20/2005 03:08:33 PM: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > [EMAIL PROTECTED] wrote: > | You should already KNOW the parent comment of a comment when you create > | it. Don't you? Imagine the following thread: > > ~ I am trying to not

Re: can a subquery be used in an insert

2005-01-20 Thread SGreen
James Black <[EMAIL PROTECTED]> wrote on 01/20/2005 02:44:41 PM: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Philippe Poelvoorde wrote: > | > | Insert into comments(list of you fields here ) > | select 0,1,null,'testuser','testcomment',max(idx) from comments > | where sourceid=1; >

Re: can a subquery be used in an insert

2005-01-20 Thread James Black
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Philippe Poelvoorde wrote: | | Insert into comments(list of you fields here ) | select 0,1,null,'testuser','testcomment',max(idx) from comments | where sourceid=1; | | but querying max(idx) is a bad idea. you could get the last inserted id | with th

Re: can a subquery be used in an insert

2005-01-20 Thread Philippe Poelvoorde
~ I want to store the parent comment to the comment being added, so I can ensure the comments are printed out in the correct order. Then, see the post earlier called "SQL schema", where there is child->parent relationship with comments. But you now when a user post a comment which is the parent

Re: can a subquery be used in an insert

2005-01-20 Thread James Black
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Philippe Poelvoorde wrote: | James Black wrote: | |> -BEGIN PGP SIGNED MESSAGE- |> Hash: SHA1 |> |> I would like to set one column to point to the auto-incrementing index |> of the last comment in the database for my application, but I am gettin

Re: can a subquery be used in an insert

2005-01-20 Thread Philippe Poelvoorde
James Black wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I would like to set one column to point to the auto-incrementing index of the last comment in the database for my application, but I am getting an error when I run my test, and so I wonder if what I am trying to do is possible. My SQ

re: can a subquery be used in an insert

2005-01-20 Thread James Black
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I would like to set one column to point to the auto-incrementing index of the last comment in the database for my application, but I am getting an error when I run my test, and so I wonder if what I am trying to do is possible. I am using mysql 5.0.1, b