3
I need to assemble a select, where I need to display the results outside a code range. For example: I have code 2 as the beginning and code 6 as the end, how could I not display the codes 3, 4 and 5 and display only code 1 and 5 onwards? Only with SQL is possible?
With this select I can not display the initial and final code, but still showing what is between them
SELECT h.cod, h.horario FROM horarios h
WHERE h.cod NOT IN (SELECT cod_hora_saida FROM reservas) AND
h.cod NOT IN (SELECT cod_hora_prevista FROM reservas)
ORDER BY h.cod ASC
UPDATE
I keep trying, but I still could not show the result I need. The tables I use are the 2 below
The result I’m trying is this, using the tables below as an example:
06:00 06:30 07:00 07:30 08:00 08:30 09:00 09:30 10:00 13:00 13:30 14:00 14:30 15:00 18:00 18:30 19:00
LAST UPDATE
I tested Union all function, with a reservation worked, but if you have more than one on the same day no longer works. Suggestions?
select * from horarios where cod < 20 union all select * from horarios where cod > 25
What have you ever tried to do?
– Wallace Maxters
Have tried SELECT * FROM table Where code >= 1 and code < 2 and code >= 5?
– Miguel Batista
Yes, he keeps showing
– Diego
edited the question with the last attempts I made.
– Diego
In your first query take the
AND
and put aOR
. Post the result!!!– StillBuggin
No, it brought as a result the entire schedule table...
– Diego