I put this where statment in and it fixed the problem. The emp_id_nr in
tblemployee was null for empnr starting with six zeros.
Josh
DELETE FROM temptblJOBEVL
WHERE (SYS_EMP_ID_NR NOT IN
(SELECT emp_id_nr
FROM tblemployee where emp_nr not like
'000000%'))
-----Original Message-----
From: Jochem van Dieten [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 15, 2002 8:53 AM
To: CF-Talk
Subject: Re: SQL HELP
Joshua Tipton wrote:
> For some unknown reason this query does not work correctly even though
> I know that there is data in temptbljobevl that does not match
> tblemployee data. Can someone please help me do this via a join.
I doubt that rewriting as a join is going to solve anything. That would
be a bug of a size that would be known, and it is not unlikely your
database does that internally anyway. Maybe better to start looking if
SYS_EMP_ID_NR and emp_id_nr don't have any NULL's, have the same
datatype, are padded the same way or something.
> SELECT *
> FROM temptblJOBEVL
> WHERE (SYS_EMP_ID_NR NOT IN
> (SELECT emp_id_nr
> FROM tblemployee))
Rewriting that requires an OUTER JOIN, which might be less than
efficient. But if you want to try:
SELECT job.*
FROM temptblJOBEVL job LEFT JOIN tblemployee emp
ON job.SYS_EMP_ID_NR = emp.emp_id_nr
WHERE emp.emp_id_nr IS NULL
I prefer the NOT EXISTS syntax, I think it is easier to read:
SELECT job.*
FROM temptblJOBEVL job
WHERE NOT EXISTS (
SELECT 1
FROM tblemployee emp
WHERE job.SYS_EMP_ID_NR = emp.emp_id_nr
)
All should return the same results, but have fun :)
Jochem
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com