0
I have this table:
Typotarefa:
Id, Descricao
17, Depilação Buço
18, Depilação Pernas
19, Depilação Orelhas
20, Depilação Barba
21, Cortar Unhas Pés
22, Cortar Unhas Mãos
28, Esvaziar Saco Urina
29, Hidratação
36, Medicação
37, Deitar Utente
47, Levar Roupa para Lavandaria
48, Arrumar Lixo
73, Encaminhamento de Utente para Deitar (Pós Almoço)
77, Fazer Cama
Then I have the Users table:
codigo, nome, quarto, cama
2, Pedro, 15, 1
6, Paulo Moura, 12, 2
3, Bruno, 12, 1
4, ANTONIO, 21, 1
Now I have the table where I register the tasks, where I already did the query that returns the tasks performed on the current day:
SELECT raddb.Tarefa.codigo, Colaborador, FimTarefa, Ala, nome, raddb.TipoTarefa.Id, Descricao
FROM raddb.Tarefa LEFT OUTER JOIN raddb.TipoTarefa ON raddb.TipoTarefa.Id = raddb.Tarefa.tarefa
LEFT OUTER JOIN raddb.quartos ON raddb.quartos.Codigo = raddb.Tarefa.codigo
LEFT OUTER JOIN raddb.Utente ON raddb.Utente.quarto = raddb.quartos.Quarto AND raddb.Utente.Cama = raddb.quartos.Cama
WHERE raddb.TipoTarefa.Id IN ('17','18','19','20','21','22','28','29','36','37','47','48','73','77') AND DATE(FimTarefa) = DATE(NOW())
That returns this:
codigo, Colaborador, FimTarefa, Ala, nome, Id, Descricao
150001, 28, 2019-07-29 11:30:08, ALA A, Pedro, 28, Esvaziar Saco Urina
110001, 33, 2019-07-29 16:10:27, ALA A, Pedro, 36, Medicação
110001, 33, 2019-07-29 17:16:27, ALA A, Pedro, 21, Cortar Unhas Pés
In the latter query
returns only three tasks performed to Peter during the day of today, the task 28,36 and 21.So what I intend is that instead of returning the tasks performed today, return me the tasks that were not performed today, which in this case were tasks 17,18,19,20,22,29,37,47,48,73,77.
Task and fourth column data:
Quarto Table:
Id, Codigo, Quarto, Cama, Ala
1, 010001, 1, 1, ALA A
2, 020101, 2, 1, ALA A
3, 020201, 2, 2, ALA A
4, 030001, 3, 1, ALA A
5, 040101, 4, 1, ALA A
6, 040201, 4, 2, ALA A
7, 050001, 5, 1, ALA A
8, 060101, 6, 1, ALA A
9, 060201, 6, 2, ALA A
10, 070001, 7, 1, ALA A
and this is the task table:
Id, codigo, IniciarTarefa, tarefa, FimTarefa, Colaborador, check, Acompnhante, Observacao, Notas, Mes, Ano, Turno
127, 110001, 2019-07-29 16:10:12, 36, 2019-07-29 16:10:27, 33, , , , Teste, 06, 2019, T
135, 110001, 2019-07-29 17:16:21, 21, 2019-07-29 17:16:27, 33, , , , , 06, 2019, T
240, 150001, 2019-07-29 11:30:02, 28, 2019-07-29 11:30:08, 28, , , , , 07, 2019, M
Tried to
right join
?raddb.Tarefa RIGHT OUTER JOIN raddb.TipoTarefa
– Edvaldo Lucena
@Edvaldo Lucena returns the same result as the
left outer join
– Bruno
Can post column data sample
Tarefa
andquartos
... I want to simulate the consultation here.– Edvaldo Lucena
@Edvaldo Lucena updated the question with the data from the task table and table rooms containing the task column and the fourth column.
– Bruno
in the table User was missing you put the fourth column, can update ?
– Edvaldo Lucena
@Edvaldo Lucena, I’ve updated the table with the bedroom column and bed
– Bruno
blz, I’ll run some tests and get back to you ...
– Edvaldo Lucena
Can make a SQL Fiddle with its current structure, data and query?
– Sorack
@Sorack I did what you asked SQL Fiddle and here returns the tasks that were performed and I intend to return the tasks that were not performed that day, of course the other columns will appear empty
– Bruno
What is unclear is what you want to return. Do you want to return a task that was not done per room? Per contributor? Demonstrate the results you want to receive
– Sorack
@Sorack lacked it, but I plan to return by room
– Bruno