Y
Yakimoto
Hi folks,
I have a problem with the left join...
I have 2 tables. The left table V contains the IDs, and the next table K
contains the data.
V ID Code
1 01
2 02
7 07
K Date VID Kilometers
7/20/2003 1 550
7/21/2003 7 777
I would like to select all the records from table V and to get the
kilometers for them from table K. If I do not specify the Date in where
clause, everything is perfect with my LEFT JOIN.
But if I specify particular date 7/20/2003 in where clause, I get only one
record as a result (ID=1).
if I specify
WHERE (((K.Date)=#7/20/2003# Or (K.Date) Is Null))
then I get 2 records (ID=1 and ID=2), but not ID=7.
Here is my SQL:
SELECT V.ID, K.Kilometers, K.Date
FROM V LEFT JOIN K ON V.ID = K.VID
WHERE (((K.Date)=#7/20/2003# Or (K.Date) Is Null))
and here is the result:
ID Kilometers Date
1 550 7/20/2003
2
I would like to have one more record, containing ID=7, but wit 0/null km,
because there is no record for this ID for that date.
Shouldn't my LEFT JOIN return all the records from my left table?
Where am I wrong?
Cheers,
Yakimoto
I have a problem with the left join...
I have 2 tables. The left table V contains the IDs, and the next table K
contains the data.
V ID Code
1 01
2 02
7 07
K Date VID Kilometers
7/20/2003 1 550
7/21/2003 7 777
I would like to select all the records from table V and to get the
kilometers for them from table K. If I do not specify the Date in where
clause, everything is perfect with my LEFT JOIN.
But if I specify particular date 7/20/2003 in where clause, I get only one
record as a result (ID=1).
if I specify
WHERE (((K.Date)=#7/20/2003# Or (K.Date) Is Null))
then I get 2 records (ID=1 and ID=2), but not ID=7.
Here is my SQL:
SELECT V.ID, K.Kilometers, K.Date
FROM V LEFT JOIN K ON V.ID = K.VID
WHERE (((K.Date)=#7/20/2003# Or (K.Date) Is Null))
and here is the result:
ID Kilometers Date
1 550 7/20/2003
2
I would like to have one more record, containing ID=7, but wit 0/null km,
because there is no record for this ID for that date.
Shouldn't my LEFT JOIN return all the records from my left table?
Where am I wrong?
Cheers,
Yakimoto