Jump to content

Copy columns data with condition


payon

Recommended Posts

Hello,

 

I need your help. I have two different tables, where I would like to copy coumns values from a specific column in table 1 to a apsecific column in table 2. But it should copy with condition. E.g.

 

Tabe1

id | date  |

---------------

0  |  23-05-2013

1  |  10-04-2013

2  |  02-01-2013

4  |  04-04-2013

40  |  04-03-2013

 

Table2

id | date |

---------------

1 |  0-0-0000

2 | 0-0-0000

3 | 0-0-0000

4 | 0-0-0000

40 | 0-0-0000

 

So I would like to copy column Table1.data to column Table2.data where Table1.id = Table2.id.

 

The problem might be, that both tables have different id entries. But all ids which are in table1 and table2 should be used for replacement of the associated data field.

 

So the result should be

 

Table2

id | date |

---------------

1 | 10-04-2013

2 | 02-01-2013

3 | 0-0-0000

4 | 04-04-2013

40 | 04-03-2013

 

Is this possible with a MySQL statement?

Link to comment
https://forums.phpfreaks.com/topic/279698-copy-columns-data-with-condition/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.