1 つのテーブル (bids_accepted) の内容全体をコピーし、テーブルのすべての行を archive_bids_accepted テーブルに配置してアーカイブしたいと考えています。これらのテーブルはまったく同じですが、archive_bids_accepted テーブルには 1 つの追加の列 (最初の列) があり、入札のセット全体に uniqueID (前のステップで作成) を与えます。
これを行うための正しい MySQL 構文は何ですか? 近いと思いますが、構文を正しく取得できません。
// gets the unique ID
long id = DBUtil.executeInsert("INSERT INTO archive (create_username,create_ts,update_username,update_ts) VALUES('', NOW(),'',NOW())");
// MySQL syntax causing problems
String sql = "INSERT INTO archive_bids_accepted VALUES(" + id + ",select * from bids_accepted)";
// Also tried this
String sql = "INSERT INTO archive_bids_accepted " + id + ",select b.* from bids_accepted b";