Refresh table field with information from another column

1

How to do an update that retrieves data from one column and plays in another column? For example

Sales

IdVenda | dataVenda  | dataPgto
1       | 2017-08-21 | 
2       | 2017-08-21 |

Do I want to update the dataPgto with the date information? PS: this sale would be made by credit card.

    
asked by anonymous 21.08.2017 / 22:07

2 answers

1

Being the same table you will not need join or something like this; just know the update condition, in this case the id of the item that will be updated idVendaEfetuada ):

UPDATE tabela_vendas SET dataPgto = dataVenda WHERE IdVenda = idVendaEfetuada
    
21.08.2017 / 22:27
1

Hello,

You just need to update by referring one column to another, for example:

UPDATE vendas SET dataPgto = dataVenda;

Here's a fiddle with a practical example:

link

    
21.08.2017 / 22:18