Link to home
Start Free TrialLog in
Avatar of Ashok
AshokFlag for United States of America

asked on

DELETE based on 2 tables

select a.*
from temp1 a, patient b
WHERE a.chart_no = b.chart_no and
b.group_assignment = 'AAA'

I have 66 records in temp1
and
above query returns 14 records.

How do I delete only 14 records from temp1?

Thanks,
Ashok
ASKER CERTIFIED SOLUTION
Avatar of wdosanjos
wdosanjos
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Som Tripathi
Ashok,
Not sure with the question.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
delete temp1
from temp1 a inner join patient b
on a.chart_no = b.chart_no and
b.group_assignment = 'AAA'
Avatar of Ashok

ASKER

wdosanjos,

I though I already tried what you have suggested,
but I guess in a hurry, I must have selected wrong (partial) delete
statement so it deleted all 66 records.

It is very simple to change UPDATE to DELETE.

Thanks,
Ashok