By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,426 Members | 1,729 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,426 IT Pros & Developers. It's quick & easy.

transfer the columns of one table into another table with condition

P: 24
hi all,

In table1, i have 6 columns and in table2, i have 10 columns.
i want to transfer 5 columns from table2 to table1 with the condition.

the condition is..

both the tables have primarykey, if the primary key in table1 matches with table2's primarykey, then we should trafer the selected column in to table1 from table2.

I want a query for the above..

Please help me in this...

Thanks in advance.
Jan 19 '07 #1
Share this Question
Share on Google+
2 Replies

Expert 2.5K+
P: 4,258
From the depth and scope of your questions I have the distinct feeling that you do not know very much about SQL. Maybe it is a good idea to get some education and follow a few starter's tutorials. For now I will help you out, but the next time you show some of your code here with which we will, of course, help you. But the idea of this forum is to have programmers help programmers, not by supplying code but by providing assistance.
Expand|Select|Wrap|Line Numbers
  1. UPDATE table2 as t2, table1 as t1 
  2.   SET 
  3.     t2.col1=t1.col1, 
  4.     t2.col2=t1.col2,
  5.     t2.col3=t1.col3,
  6.     t2.col4=t1.col4,
  7.     t2.col5=t1.col5,
  8.   WHERE t2.keycol = t1.keycol
Ronald :cool:
Jan 19 '07 #2

P: 24
Hi thanks for the query...

I already mentioned that i am newly started to program...
I have already started to study PHP-MySQL.
I tried that but I couldn't.
Next time defenitly, i will come with my code...
Jan 20 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.