I have about 15 fields I need to extract from a DB table.
Rather than my counting how many I need to add, and then copy the exact titles, and field types and characters, can I not just select each field I was to export, and then import that into the current table - but NOT import/export the data within them?
MySQL database.
Can you export columns, and then import them to another tbl?
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Can you export columns, and then import them to another tbl?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Can you export columns, and then import them to another
You can SELECT specific fields from one table and INSERT the SELECTed data into another table in one SQL statement.
(#10850)
Re: Can you export columns, and then import them to another
I think you are asking about modifying a table structure to add columns which exist in another table. Are you trying to create a new table with just those columns, or do you want to add those columns to an existing table? If you want to create a new table with exactly the same columns as another table, you could use SHOW CREATE TABLE http://dev.mysql.com/doc/refman/5.1/en/ ... table.html and save the output to a file and then execute that file as SQL, which will create an empty table structure with the same structure as the first one. If you want to add additional columns to an existing table, though, there's no easy way to do that without requiring more fuss and bother than just carefully using ALTER TABLE commands for 15 columns.simonmlewis wrote:I have about 15 fields I need to extract from a DB table.
Rather than my counting how many I need to add, and then copy the exact titles, and field types and characters, can I not just select each field I was to export, and then import that into the current table - but NOT import/export the data within them?
MySQL database.