Simple Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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?
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top