Update in same table

-2

I have this table like this:

CODIGO_AULA DATA_AULA  TURMA
----------- ---------- ----------
1           2018-01-19 MEC-001
2           2018-01-19 MEC-001
1           2018-01-20 MEC-001
2           2018-01-20 MEC-001
1           2018-01-21 MEC-001
2           2018-01-21 MEC-001
1           2018-01-22 MEC-001
2           2018-01-22 MEC-001

I need to do an update in the same one according to this past situation, I went by parameter the date: 2018-01-20

Getting :

1           2018-01-21 MEC-001
2           2018-01-21 MEC-001
1           2018-01-22 MEC-001
2           2018-01-22 MEC-001
1           2018-01-23 MEC-001
2           2018-01-23 MEC-001

It will only move from the date I passed to the end of the table. What I need and get is to do an update of the date I went through and came up?

    
asked by anonymous 22.01.2018 / 18:02

3 answers

0

Good afternoon,

This very vague your need, if you want to make an update between a range of dates utlize BETWEEN

update suaTabela set seuCampo = seuDado where seuCampo between dataInicial and dataFinal;
    
22.01.2018 / 20:24
0

As far as I understand, a WHERE in your UPDATE is missing for you to make the desired change, as a suggestion, use a predicate with the date:

UPDATE TBL_AULA SET CAMPO_A_ALTERAR = VALOR_ALTERADO WHERE DATA > '2018-01-20';
    
22.01.2018 / 20:43
0

On UPDATE, the other answers are ok and I agree that it's a bit confusing to understand. But just to clarify further:

UPDATE TBL_AULA SET DATA_AULA = '2018-01-23' WHERE DATA = '2018-01-20'; 

With this, all the records of the 20th will become the 23rd.

Considering this question: "It will only move from the date I passed to the end of the table. What do I need to do and get it to update the date I've been uploading?"

Once you've made this UPDATE, the order of the records in your table will not change. It will look like this:

CODIGO_AULA DATA_AULA  TURMA
----------- ---------- ----------
1           2018-01-19 MEC-001
2           2018-01-19 MEC-001
1           2018-01-23 MEC-001
2           2018-01-23 MEC-001
1           2018-01-21 MEC-001
2           2018-01-21 MEC-001
1           2018-01-22 MEC-001
2           2018-01-22 MEC-001

If you want it to appear in order, you will have to make an orderly selection (SELECT with ORDER BY) taking into account the DATA_AULA field.

    
23.01.2018 / 17:11