Select Mysql query ports used?

0

asked by anonymous 15.05.2017 / 03:06

1 answer

0

I made using IN, but it can also be done using NOT EXISTS.

If you want to know which particular switch ports you're not using could do this:

select switch.nome,
       (
         select group_concat(porta.porta)
         from sw_porta as porta
         where porta.id not in (
                                 select switch_cliente.id_porta
                                 from sw_local_cliente as switch_cliente
                                 where switch_cliente.id_porta = porta.id and
                                       switch_cliente.id_sw = switch.id
               )
       ) as portas_nao_utilizadas
from sw_local as switch

If you want to know which port is not being used on any switches, you could do this:

select
  *
from
  sw_porta as porta
where
  porta.id not in (
    select
      switch_cliente.id_porta
    from
      sw_local_cliente as switch_cliente
  )

Would that be what you want?

    
15.05.2017 / 16:37