Jan 24, 2002 #1 ZPlay Technical User Jan 10, 2002 24 US I am trying to insert into a table the last record from another table. I tried this statement but all I got was an error. INSERT INTO t1 SELECT * FROM t2 ORDER BY id DESC LIMIT 1 Is there another way to do this?
I am trying to insert into a table the last record from another table. I tried this statement but all I got was an error. INSERT INTO t1 SELECT * FROM t2 ORDER BY id DESC LIMIT 1 Is there another way to do this?
Jan 24, 2002 #2 braindead2 Technical User Nov 11, 2010 647 GB INSERT INTO t1 SELECT * FROM t2 where id = max(id) Upvote 0 Downvote
Jan 25, 2002 1 #3 tlbroadbent MIS Mar 16, 2001 9,982 US You can also use this. INSERT INTO t1 SELECT Top 1 * FROM t2 ORDER BY id DESC Terry L. Broadbent Programming and Computing Resources http://tlbroadbent.home.attbi.com/prog.htm Upvote 0 Downvote
You can also use this. INSERT INTO t1 SELECT Top 1 * FROM t2 ORDER BY id DESC Terry L. Broadbent Programming and Computing Resources http://tlbroadbent.home.attbi.com/prog.htm
Jan 25, 2002 Thread starter #4 ZPlay Technical User Jan 10, 2002 24 US Well I tried Braindead2's solution first and Access gae me this error message: cannot have aggregate function in WHERE clause (id=max(id)) I then tried tlbroadbents method and that seems to work perfectly. Thanks for your responses and help. Upvote 0 Downvote
Well I tried Braindead2's solution first and Access gae me this error message: cannot have aggregate function in WHERE clause (id=max(id)) I then tried tlbroadbents method and that seems to work perfectly. Thanks for your responses and help.