Select between 2 tables

2

Based on the tables below and passing the 'start date' and 'dataFim', would it be possible with only one Select select from the Vehicle Table only vehicles that are not in the Reserve Table? I'm studying Inner Join, but I have no idea if this is possible.

Tabela Veiculo
--------------
idVeiculo
nomeVeiculo


Tabela Reserva
--------------
idVeiculo
dataInicio
dataFim
    
asked by anonymous 17.05.2016 / 05:33

1 answer

2

The first thing to do is to create a key for the relationship between the two tables, after that, it would look like this:

SELECT v.nomeVeiculo FROM VEICULO v
INNER JOIN RESERVA r on v.id not in r.veiculo_id;
    
17.05.2016 / 05:39