Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
begin tran --rollback tran
insert into nfc_DeliveryPlan (patient_id,contact_id,isactive,createddate,modifieddate,CreatedUserId)
select patient_id, contact_id, 1, '2013-12-05', NULL, patient_id from nfc_careplan_contacts
where contact_id not in (select contact_id from nfc_DeliveryPlan where contact_id = 420)
and contact_id = 420
Posted
Updated 6-Dec-13 7:47am
v2
Comments
What have you tried?

1 solution

Your query never return any result! because of your terms which are always false!
for not in you can use join, that's more optimize!
SQL
String query = "select patient_id, contact_id, 1, '2013-12-05', NULL, patient_id from nfc_careplan_contacts a left join nfc_DeliveryPlan b on a.contact_id = b.contact_id where a.contact_id = 420 and b.contact_id = 420 and a.contact_id != b.contact_id) and a.contact_id = 420;";
Cursor c = database.rawQuery(query, null);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900