LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-18-2007, 12:33 PM   #1
tooparam
Member
 
Registered: Nov 2005
Location: India
Distribution: Slackware
Posts: 51

Rep: Reputation: 15
Wink sql command to copy column from a table


Hi Friends

I know how to copy a complete table structure from one database to another

create table ".$db2.".".$table." like ".$db1.".".$table

but how do I copy a single column from a given table to another table?

Is there any sql command for doing this?
 
Old 06-19-2007, 05:21 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,287

Rep: Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034
insert into table2 (col2) select col1 from table1 (for data)
iirc, at least in Oracle you could also do:
create table table2 as select col1 from table1 to create (and fill ?)
It's been a while; don't think MySQL supports that, I could be wrong ...

Last edited by chrism01; 06-19-2007 at 05:28 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL statement to get the last row in a table oulevon Programming 11 04-03-2009 08:30 PM
Sql table relationship question anickless Programming 5 03-03-2006 05:21 PM
SQL question: Need to add a column from another table Hivemind Programming 3 09-19-2005 06:02 PM
Finding the name and data type of a column in SQL Travis86 Programming 11 08-15-2004 04:20 PM
help on finding the number that has max occurrences in a column [sql query] zeppelin Programming 6 06-15-2004 01:41 PM


All times are GMT -5. The time now is 07:37 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration