Link to home
Create AccountLog in
Avatar of Roman F
Roman FFlag for United States of America

asked on

Please help me with the query

let say you run the query
Select * from tblMain

if you have the data you will get result:
num   name     zip
1      Steven 91356
2     Leonad 94875
and so on...
how about if you do not have anything you will get this
num   name     zip
how to modify the query and get just something like this:
0
Avatar of Armen Stein - Microsoft Access MVP since 2006
Armen Stein - Microsoft Access MVP since 2006
Flag of United States of America image

That's not how queries work.  They return records if they exist, not if they don't.  Can you tell us what you are trying to accomplish with this "zero" record?
Try this.
Select num,name,zip from tblMain
union all
select 0,null,null where not exists (select 1 from tblMain)

Open in new window

Avatar of Roman F

ASKER

Thank you, guys.
To ArmenStein:i need to get the count of records even if there is no records. ---in this case is Zero is my result. I need the count to add to one more query results to get the final number
To: Sharath_123: i am getting the error message
Syntax error(missing operator) in query exression 'null where not exists (select 1 from tblMain)
'
Check this
Select num,name,zip from tblMain
union 
select 0,null,null from tblMain where not exists (select 1 from tblMain)

Open in new window

Avatar of Roman F

ASKER

thank you, it did not give me the error, but it does not give me the zero
i added the extra field Date
what i want, i think it make more sense, show me * from the table where date is not todays

and it stll gives me just a header:
num name zip Date

and i want like that
num name zip Date
0
is this possible???
Select num,name,zip,Date from tblMain where Date =format(now,"mm/dd/yyyy")
union 
select 0,null,null,null from tblMain where not exists (select 1 from tblMain)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Sharath S
Sharath S
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer