Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL QUERY HELP

Author  Topic 

lfmn
Posting Yak Master

141 Posts

Posted - 2001-10-24 : 08:58:26
I'm having problems with the following query (from inherited code)'

SELECT test_tbl.*, test_lu_impact_tbl.impact_name, usr_tbl.l_name,
usr_tbl.f_name + ' ' + usr_tbl.l_name AS FullName,
usr_tbl_2.f_name + ' ' + usr_tbl_2.l_name as BFullName,
test_lu_likelihood_tbl.likelihood_name, test_lu_org_tbl.org_name,
test_lu_project_area_tbl.pa_name , ActiveSW
FROM test_tbl
LEFT OUTER JOIN test_lu_impact_tbl ON test_tbl.impact_id = test_lu_impact_tbl.impact_id
LEFT OUTER JOIN usr_tbl ON test_tbl.primary_ao_id = usr_tbl.usr_id
LEFT OUTER JOIN usr_tbl as usr_tbl_2 ON test_tbl.backup_ao_id = usr_tbl_2.usr_id
LEFT OUTER JOIN test_lu_likelihood_tbl ON test_tbl.likelihood_id = test_lu_likelihood_tbl.likelihood_id
LEFT OUTER JOIN test_lu_org_tbl ON test_tbl.org_id = test_lu_org_tbl.org_id
LEFT OUTER JOIN test_lu_project_area_tbl ON test_tbl.test_id = test_lu_project_area_tbl.pa_id
and ActiveSW = 1
ORDER BY test_tbl.test_id DESC

The ActiveSW column is in the test_tbl and the problem is that the 'ActiveSW = 1' is being
ignored. Records are showing up even where ActiveSW = 0. I'm not used to writing in this
style and would appreciate any help.

cursors are like hammers - sometimes you have to use them, but watch your thumb!
   

- Advertisement -