Question : Simple SQL question, filter only gives records that have url, want null also

Hey gang,

Quick question. I am trying to do a query that adds a url field to the query, but only has 10 people that have a url currently. I have 700 people that show up without the url, but adding the url field (CustomStudent.attributeID = 365) only filters the people to the 10 that have a url. I want to show all people with or without a url. I have tried all types of joins with the 3 tables and still can't get it to work. Any ideas.

SELECT DISTINCT
                         staffMember.staffNumber, staffMember.lastName, staffMember.firstName, staffMember.title, staffMember.departmentName, staffMember.schoolName,
                         staffMember.schoolID, RIGHT(sif_StaffPersonal.workPhone, 5) AS Ext, sif_StaffPersonal.email, staffMember.endDate, CustomStudent.value
FROM            CustomStudent INNER JOIN
                         staffMember INNER JOIN
                         sif_StaffPersonal ON staffMember.personID = sif_StaffPersonal.personID ON CustomStudent.personID = sif_StaffPersonal.personID
WHERE        (staffMember.endDate IS NULL) AND (CustomStudent.attributeID = 365)
ORDER BY staffMember.lastName

Answer : Simple SQL question, filter only gives records that have url, want null also

This is how you want to add the value from CustomStudent which may or may not be there for all records.  Outer Join to it and include the =365 condition in the Join instead of in the where.
HTH on that question.
On another note, the DISTINCT is suspect to me as I always wonder why someone has to add a Distinct, why are there duplicates in the first place?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
SELECT DISTINCT
        staffMember.staffNumber,
        staffMember.lastName,
        staffMember.firstName,
        staffMember.title,
        staffMember.departmentName,
        staffMember.schoolName,
        staffMember.schoolID,
        RIGHT(sif_StaffPersonal.workPhone, 5) AS Ext,
        sif_StaffPersonal.email,
        staffMember.endDate,
        CustomStudent.value
FROM    staffMember
INNER JOIN sif_StaffPersonal ON staffMember.personID = sif_StaffPersonal.personID 
LEFT OUTER JOIN CustomStudent ON CustomStudent.personID = sif_StaffPersonal.personID AND CustomStudent.attributeID = 365
WHERE   ( staffMember.endDate IS NULL )
ORDER BY staffMember.lastName
Random Solutions  
 
programming4us programming4us