Access Query null values

  • Thread starter Thread starter marcosruapuga
  • Start date Start date
M

marcosruapuga

Hello,

how can i do to perform a query in acces with null values.

I have a table with the following:

People
----------------
NamePeople
Zone

Zones
----------------
IdZone
Zone

Select * from People Left Join Zones On Pepople.Zone = Zones.IdZone AND
Zone=[Zone]

Some people have not zones, how can I select it. How can I do when
Access ask to value of Zone to select Null values.

Thanks.
 
Even without the issue of Zone being Null, that query won't work, as your
second condition (Zone=[Zone]) is going to raise an error that Zone is
ambiguous. You need to indicate which Zone you're trying to compare to your
input: the one in the People table, or the one in the Zones table.

I'm assuming that you're trying to input a value to compare to the field
Zones.Zone. If that's the case, try:

Select * from People Left Join Zones On Pepople.Zone = Zones.IdZone
WHERE Zones.Zone=[Zone] OR [Zone] IS NULL

That will allow you to simply hit Enter when the prompt for Zone appears,
and all rows will be returned. If all you want returned are those rows that
all Null, try

Select * from People Left Join Zones On Pepople.Zone = Zones.IdZone
WHERE Zones.Zone=[Zone] OR ([Zone] IS NULL AND Zones.Zone 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