Hello Vinish Sir,
I need your little help if possible.
I have 2 tables
(1) CONTACT_TYPES table as below:
Contact_Type_Id Contact_Type_Description
————— ————————
1 Alternate Contact Number
2 Email
3 Fax
4 Website
5 Twitter
6 Facebook
7 Linkedin
8 Preferred Contact Number
(2) PERSON_CONTACT_DETS table as below:
Person_Contact_Det_Id Person_Id Contact_Type_Id
——————— ——– —————
1 11111 1
2 11111 8
3 22222 1
4 22222 2
I need a query to show person_id with contact types NOT already selected for a person as below: (if person_id is 11111)
Person_Id Contact_Type_Id Contact_Type_Description
——— ————— ————————
11111 2 Email
11111 3 Fax
11111 4 Website
11111 5 Twitter
11111 6 Facebook
11111 7 Linkedin
Your help and support would be appreciated.
Kind Regards,
Bhavin
Try this one:
Many thanks for your prompt reply but this query won’t work…!
Any way I found the solution based on the above query:
SELECT DISTINCT
p.person_id
,c.contact_det_type_id
,c.description
FROM per_contact_dets p
,contact_det_types_lk c
WHERE p.person_id = :person_id
AND c.contact_det_type_id NOT IN (SELECT p1.contact_det_type_id
FROM per_contact_dets p1
WHERE p1.person_id = p.person_id)
;