Doubt in a Query that does SELECT on two tables

0

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

  • Each schedule has a numbering of the equipment that will be used in that time range.
  • You can not use two devices at the same time.
  • Each device has specific software installed on it (can be installed on more than one device).
  • And for this I'm dealing with a function. (My job is a mess and the embarrassment of posting here) This function is preventing conflicts but is still having some problems.

    I was trying to query to select Cars that CONTAIN Software X and that 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, however this query returns all the cars that are being used today

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

        
    asked by anonymous 01.12.2016 / 15:39

    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' 
    
        
    01.12.2016 / 19:37