"dev" <NO***********************@hotmail.com> wrote in message
news:40*********************@news.xs4all.nl...
how create a temp table as a copy of a existing table and then update1
field and insert the hole temp table back in the existing table?
please any help?
if i have 10 fields in 1 record and about 100 records and a field.status=1
in a existing_table and
i want to create a temp_table with all the recordse and values of the
existing_table and then update the field.status to 2 and insert in 1
query the temp_table in the existing_table
Try this, pulled straight from the MySQL on-line manual.
=======
As of MySQL 3.23, you can create one table from another by adding a SELECT
statement at the end of the CREATE TABLE statement:
CREATE TABLE new_tbl SELECT * FROM orig_tbl;
MySQL will create new column for all elements in the SELECT.
=======
I haven't tested it myself, but it looks like what you need, followed by the
necessary UPDATE statements. I don't think it will build your indexes and
such, but if you are content with copying the whole table, you probably
don't need supporting indices.
If you're using MySQL 4.1, there is a 'CREATE TABLE new_tble LIKE old_tbl'
syntax as well. That, I think retains the characteristics of the table,
including indices.
Again, haven't tried these myself. Just exploring along with you.
- Virgil