this is an excellent question that trips up a lot of people.
try both of these queries and see the results should be different:
select * from table a
left outer join table b on b.testid = a.testid
and test_code = '20'
select * from table a
left outer join table b on b.testid = a.testid
WHERE test_code = '20'
the difference, if it is not obvious, is that the second query does not use test_code = '20' as part of the JOIN, but instead tests the results of the join with the WHERE.
unless you really had a compound condition for the join, you want to move the part that tests the data to the WHERE clause.
Lowell
--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!