Simple Query

N

nir020

I have created two tables, they are area (which contains the fields area name
and ID) and data (which contains the fields areacode and datecode) and are
connected by the field areacode.

Is is possible to create a query which dislays the areas which have do not
have a datecode of 2?

Thanks

Nick
 
M

Marshall Barton

nir020 said:
I have created two tables, they are area (which contains the fields area name
and ID) and data (which contains the fields areacode and datecode) and are
connected by the field areacode.

Is is possible to create a query which dislays the areas which have do not
have a datecode of 2?


I think this might do it:

SELECT A.AreaName
FROM Area As A
LEFT JOIN (
SELECT D.AreaCode
FROM Data As D
WHERE D.AreaCode = A.ID
AND D.DateCode = 2) As X
WHERE X.AreaCode Is Null
 
N

nir020

Thanks for this but it does not seem to be working, i keeping getting the
error message "syntak error in FROM clause

can you help?
 
M

Marshall Barton

Sorry, I got myself more mixed up than usual. Let's try
this instead:

SELECT A.AreaName
FROM Area As A
LEFT JOIN (
SELECT D.AreaCode
FROM Data As D
WHERE D.DateCode = 2) As X
ON X.AreaCode = A.ID
WHERE X.AreaCode Is Null
 
Top