Anderson M. Anderson M. - 1 month ago 6
MySQL Question

Mysql error with time range from subquery

I need to check the start and end times to have the time available for scheduling. But it produces an error when I include both the start and end time columns.

SELECT horariosfixos
FROM agendamento_horarios
WHERE horariosfixos NOT IN(SELECT horaInicio,horaFim
FROM agendamento
WHERE data = '17-10-2016'
ORDER BY horaInicio ASC)



Error: #1241 - Operand should contain 1 column(s)

Answer
SELECT horariosfixos 
FROM agendamento_horarios 
WHERE horariosfixos NOT IN(SELECT horaInicio 
                           FROM agendamento 
                           WHERE data = '17-10-2016' 
                           UNION 
                           SELECT horaFim as horaInicio
                           FROM agendamento 
                           WHERE data = '17-10-2016')
Comments