Duvída in a Query that selects in two tables

Asked

Viewed 69 times

0

Good afternoon, I am making a system of equipment scheduling, for better understanding I will put on topics some important information.

  1. Each schedule has a numbering of the equipment that will be used in that time range.
  2. Two devices cannot be used at the same time.
  3. Each piece of equipment has specific software installed on it (it may be installed on more than one piece of equipment).

And for that I am dealing with a function. (My function is a mess and the shame of posting here) This function is avoiding conflicts but is still having some problems.

I was trying to do a query to select Cars that CONTAIN X Software and are not being used on the current day

SELECT DISTINCT ls_software.* FROM ls_agendamentos INNER JOIN ls_software ON ls_agendamentos.data = '2016-12-01' AND ls_software.carro != ls_agendamentos.carro AND ls_software.nome = 'avocado'

This was the attempt, but this query returns all the cars that are being used today

Follow the photo of the tables for a better example understanding.

Tabela de Agendamentos Tabela de Software

1 answer

-2

Try the following Query:

SELECT ls_software.* 
FROM ls_agendamentos 
INNER JOIN ls_software 
ON ls_software.id = ls_agendamentos.carro 
WHERE ls_agendamentos.data != '2016-12-01'
AND ls_software.nome = 'Abacate' 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.