nichemtktg — 2012-06-30T19:13:12-04:00 — #1
I need to move a row from one table to another table that shares the same structure. Is there a way to do that with wildcards?
I thought something like this might work, but no go.
mysql_query("INSERT INTO trkg_arc (*) SELECT * FROM trkg WHERE id = 3") or die(mysql_error());
system — 2012-06-30T19:17:43-04:00 — #2
Maybe lose the (*) on INSERT:
INSERT INTO trkg_arc SELECT * FROM trkg WHERE id = 3
nichemtktg — 2012-06-30T19:26:26-04:00 — #3
Thanks itmitică. That worked.
system — 2012-06-30T19:35:08-04:00 — #4
nichemtktg — 2012-06-30T21:50:41-04:00 — #5
"Captain, the most elementary and valuable statement in science, the beginning of wisdom, is 'I do not know.'" - Lt. Commander Data, Star Trek TNG
rcashell — 2012-07-02T12:57:08-04:00 — #6
It is better programming practice to both name the columns from the table being inserted and the table being selected. For example, let's imagine you add a new column to one table. Your code would all of a sudden stop working. Likewise if you rebuild your table and reorder the columns then you will get very strange results.
mittineague — 2014-09-22T11:42:41-04:00 — #7
This topic is now archived. It is frozen and cannot be changed in any way.