SQL [message #373277] |
Mon, 09 April 2001 14:16 |
aish74
Messages: 19 Registered: March 2001
|
Junior Member |
|
|
Hi gurus,
Can any one help me on this
I have two tables emp_details and job details ,and jobcode is PK/Fk between the two tables.
I want to delete all jobcodes that have not been assigned to any active(working) employee ((flag “Y” or “N”).
For Ex the values in the tables are
Employee details Job details table
Emplid jobcode active_cd
10011 1433 Y
10022 1433 N
10012 1433 N
10033 1544 N
10044 1544 N
jobcode table
1433
1544
1622
The SQL statement I am using is
Delete from employee details
where jobdetails. jobcode =empl.jobcode
and active cd=’N’
It is also deleting the jobcode 1433 (it has one active employee 10011 and sholud not be deleting .
I know there should be some way could any one help me.
Thanks,
imrsur
|
|
|
Re: SQL [message #373278 is a reply to message #373277] |
Mon, 09 April 2001 14:54 |
Madhav Kasojjala
Messages: 42 Registered: November 2000
|
Member |
|
|
Hi
It should be
Delete from employee details a
where a.jobcode in (select job_code from
job_details)
and active_cd=’N’
hth
Madhav
|
|
|