-----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 getting |> an error when I run my test, and so I wonder if what I am trying to do |> is possible. | | |> My SQL command is: |> INSERT INTo comments VALUES(0, 1, NULL, 'testuser', 'this is a test |> comment', (SELECT max(idx) FROM comments WHERE sourceid=1)) | | | Try : | | 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 the following command : | SELECT last_insert_id() from comments LIMIT 1; | | the last_insert_id is available on a per connection basis. | | but why are you inserting back in comments a field from comments ??? |
~ 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.
~ I will try putting in my list of fields, and see if that works any better.
~ I am writing a wiki, and I am trying to store the comments for each wiki into my database now. :)
~ Thank you for your response, btw.
- -- "Love is mutual self-giving that ends in self-recovery." Fulton Sheen James Black [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFB78nPikQgpVn8xrARAsiPAJ4kowIdeqUUgTyzn2oelHhBh/4khACeOaeQ 9IhVMUjrn38PPAnTAzLblKU= =A2Mi -----END PGP SIGNATURE-----
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]