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
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.