"Roy Walker" <[EMAIL PROTECTED]> wrote: > > Thanx for your help. Still having an issue with this. I forgot to mention I am > running MySQL 4.0.13. Tried both of these statements: > > INSERT INTO table2 (id,count,period_count,date) SELECT id as id1, count, (count - > (SELECT count FROM table2 WHERE id=id1 order by timestamp desc > limit 1)) AS period_count, (TO_DAYS(NOW() -1)) from table 1; > > INSERT INTO table2 (id,count,period_count,date) SELECT @id1:=id, count, > (count - (SELECT count FROM table2 WHERE [EMAIL PROTECTED] order by timestamp desc > limit 1)) AS period_count, (TO_DAYS(NOW() -1)) from table 1; > > They both give me an error for the 'SELECT count FROM table2 WHERE id=id1' section. > Is this illegal syntax? Would this be considered a subselect?
1. 4.0.1 is too old and unstable version. 2. You can't insert data into the table, which you use in the SELECT part too (table2). Retrieve data from table2 to the temporary table and then insert data to the table2 using table1 and temporary table. -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Egor Egorov / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net <___/ www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]