list records that has and a table and not in another

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Thu, 09 Mar 2006 10:33 am

Hi guys I have a problem: I have a table of patients who have diabetes and a table of patients who have diabetes but makes use of insulin so I would need to list these two groups the patient has diabetes and those who have diabetes and insulin use without repetílos thank you in advance
Joao Moraes
Location: Botucatu - SP

Poston Thu, 09 Mar 2006 10:40 am

Can do so: these are they who have diabetes and are using insulin:
Code: Select all
select cod, nome
from tabela_diabetes_insulina
these are they who have diabetes only. (do not repeat that use insulin)
Code: Select all
select a.cod, a.nome
from tabela_diabetes a
where not exists
  (select 1
   from tabela_diabetes_insulina b
   where a.cod = b.cod
  )





:-o
dr_gori
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?
http://glufke.net/oracle/search.php?search_id=unanswered

Poston Fri, 10 Mar 2006 11:10 am

you're the man!!!
I want to thank you for the tip helped me a lot!
:-o
Joao Moraes
Location: Botucatu - SP


  • See also
    Replies
    Views
    Last Post


Return to SQL

Who is online

Users browsing this forum: No registered users and 2 guests