I have two tables. One is called prem and contains all ids that exist in a system, and JimsQueryByColl which has most of those ids with various information attached. I am trying to create a single query that will include all of the ids from prem, and all of the records from the JimsQueryByColl where JimsQueryByColl.Collector = “Frederick Road”. The current query I have is as follows but only gives the latter part of the information (without the ids from the prem that don’t appear in a list of ids with Frederick Road in the collector collumn):
SELECT Prem.meter_miu_id,
JimsQueryByColl.*, Prem.longitude,
Prem.latitude
FROM Prem LEFT JOIN
JimsQueryByColl ON Prem.meter_miu_id =
JimsQueryByColl.[MIU ID]
WHERE
(((JimsQueryByColl.Collector)=”Frederick
Road”))
Normally the Left Join would have achieved what i desire but the where statement is making it where the ids that would have blank information for all but the *Prem.meter_miu_id* field are not included. I have tried to add an “or JimsQueryByColl.Collector IS NULL” to the WHERE statement but that didn’t get the correct result.
The current two query method I have for getting the right information are titled FredrickRoad and Query3:
FredrickRoad-
SELECT JimsQueryByColl.* FROM
JimsQueryByColl WHERE
(((JimsQueryByColl.Collector)=”Frederick
Road”))
Followed by Query3 –
SELECT Prem.meter_miu_id,
JimsQueryByColl.*, Prem.longitude,
Prem.latitude FROM Prem LEFT JOIN
JimsQueryByColl ON Prem.meter_miu_id =
JimsQueryByColl.[MIU ID] WHERE
(((JimsQueryByColl.Collector)=”Frederick
Road”));
But I would like to do this in one step if possible. I hope I have written this clearly and if someone needs clarification just ask.
Current Solution
SELECT Prem.meter_miu_id,
JimsQueryByColl.*, Prem.longitude,
Prem.latitude
Into FrederickRoad
FROM Prem LEFT JOIN
JimsQueryByColl ON (Prem.meter_miu_id
= JimsQueryByColl.[MIU ID]
AND JimsQueryByColl.Collector=”Frederick
Road”)
This gets around the odd bug/error I’m getting with the query since it puts it into a table and doesn’t deal with the query directly again. I would however love to know what is causing the problems I’m having.
Try: