P
Peter Carlson
The following sql selects a "person"
SELECT A.*, (E.last+', ') & (E.first) & (' '+E.middle) AS
emergency_fullname, S.status AS statust, R.rank AS rankt FROM ((person AS A
LEFT JOIN Person AS E ON A.emergency = E.id) INNER JOIN tPersonnel_Status AS
S ON A.status = S.id) INNER JOIN tPersonnel_Rank AS R ON A.rank = R.id WHERE
A.id=%id%;
%id% being replaced with the record ID of the person
however there are times when A.status or A.rank is = 0 (or no status, no
rank) A.status and A.rank are integers that point to autonumber id's in the
appropriate status and rank tables. When status or rank = 0 then the
"person" record is not retrieved becauase it cant find an appropriate entry
in the status or rank tables. Is there a way to do this? What I need is
basically this:
tPerson
id, last, emergency, status, rank
1, carlson, 2, 1, 1
2, smith, 0, 0, 0
tStatus
id, status
1, active
2, retired
tRank
1, Chief
2, Asst. Chief
select id1=
1, carlson, 2, active, Chief
select id2=
2, smith, 0, '', ''
I'd like to keep it as generic sql as possible since this *might* hit other
databases, but primarily hits access.
Peter
SELECT A.*, (E.last+', ') & (E.first) & (' '+E.middle) AS
emergency_fullname, S.status AS statust, R.rank AS rankt FROM ((person AS A
LEFT JOIN Person AS E ON A.emergency = E.id) INNER JOIN tPersonnel_Status AS
S ON A.status = S.id) INNER JOIN tPersonnel_Rank AS R ON A.rank = R.id WHERE
A.id=%id%;
%id% being replaced with the record ID of the person
however there are times when A.status or A.rank is = 0 (or no status, no
rank) A.status and A.rank are integers that point to autonumber id's in the
appropriate status and rank tables. When status or rank = 0 then the
"person" record is not retrieved becauase it cant find an appropriate entry
in the status or rank tables. Is there a way to do this? What I need is
basically this:
tPerson
id, last, emergency, status, rank
1, carlson, 2, 1, 1
2, smith, 0, 0, 0
tStatus
id, status
1, active
2, retired
tRank
1, Chief
2, Asst. Chief
select id1=
1, carlson, 2, active, Chief
select id2=
2, smith, 0, '', ''
I'd like to keep it as generic sql as possible since this *might* hit other
databases, but primarily hits access.
Peter