What is wrong with this Select Statement

A

Ayo

I keep getting a syntax error (missing operator) message and I can't figure
out what is wrong.

"SELECT * FROM [InScope Table] WHERE ((([Extended Price])<>0) AND (([Funding
Request Status])="Approved") AND (([AT&T Extended Price])=0)) AND [Project
Number]=062G4311 AND [Task Number]=3000"
 
D

Dirk Goldgar

Ayo said:
I keep getting a syntax error (missing operator) message and I can't figure
out what is wrong.

"SELECT * FROM [InScope Table] WHERE ((([Extended Price])<>0) AND
(([Funding
Request Status])="Approved") AND (([AT&T Extended Price])=0)) AND [Project
Number]=062G4311 AND [Task Number]=3000"


Is that a quoted literal string? It has quotes inside the quotes (around
"Approved"). If that's the problem, you can use single-quotes (') inside
the literal instead of the double-quotes:

"SELECT * FROM [InScope Table] WHERE ((([Extended Price])<>0) AND (([Funding
Request Status])='Approved') AND (([AT&T Extended Price])=0)) AND [Project
Number]=062G4311 AND [Task Number]=3000"
 
A

Ayo

I did that and it didn't work. Still got the same message.

Dirk Goldgar said:
Ayo said:
I keep getting a syntax error (missing operator) message and I can't figure
out what is wrong.

"SELECT * FROM [InScope Table] WHERE ((([Extended Price])<>0) AND
(([Funding
Request Status])="Approved") AND (([AT&T Extended Price])=0)) AND [Project
Number]=062G4311 AND [Task Number]=3000"


Is that a quoted literal string? It has quotes inside the quotes (around
"Approved"). If that's the problem, you can use single-quotes (') inside
the literal instead of the double-quotes:

"SELECT * FROM [InScope Table] WHERE ((([Extended Price])<>0) AND (([Funding
Request Status])='Approved') AND (([AT&T Extended Price])=0)) AND [Project
Number]=062G4311 AND [Task Number]=3000"



--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
J

Jeanette Cunningham

Ayo,
the bit that is wrong is the quotes around Approved.
try
'Approved'

or

""Approved""

Jeanette Cunninghan
 
D

Dirk Goldgar

Ayo said:
I did that and it didn't work. Still got the same message.

I just noticed another thing. You also need quotes around "062G4311":

"SELECT * FROM [InScope Table] WHERE ((([Extended Price])<>0) AND (([Funding
Request Status])='Approved') AND (([AT&T Extended Price])=0)) AND [Project
Number]='062G4311' AND [Task Number]=3000"
 
A

Ayo

Neither worked. The problem seem to be centered around this section WHERE
((([Extended Price])<>0) AND (([Funding Request Status])="Approved") AND
(([AT&T Extended Price])=0)) AND [Project Number]=062G4311 AND [Task
Number]=3000
IAnd I can't figure out what the missing operator is.


Jeanette Cunningham said:
Ayo,
the bit that is wrong is the quotes around Approved.
try
'Approved'

or

""Approved""

Jeanette Cunninghan


Ayo said:
I keep getting a syntax error (missing operator) message and I can't figure
out what is wrong.

"SELECT * FROM [InScope Table] WHERE ((([Extended Price])<>0) AND
(([Funding
Request Status])="Approved") AND (([AT&T Extended Price])=0)) AND [Project
Number]=062G4311 AND [Task Number]=3000"
 
J

John W. Vinson

Is that a quoted literal string? It has quotes inside the quotes (around
"Approved"). If that's the problem, you can use single-quotes (') inside
the literal instead of the double-quotes:

and since Project Number is a Text field it needs quotes too:

"SELECT * FROM [InScope Table] WHERE ((([Extended Price])<>0) AND (([Funding
Request Status])='Approved') AND (([AT&T Extended Price])=0)) AND [Project
Number]='062G4311' AND [Task Number]=3000"

If Task Number is also Text instead of Number, it will also need quotes.

John W. Vinson [MVP]
 
J

Jeanette Cunningham

Perhaps the Task number is a text field also?

Try "SELECT * FROM [InScope Table] WHERE [Extended Price]<>0"

if that bit works without the error then try
"SELECT * FROM [InScope Table] WHERE [Extended Price]<>0 AND (([Funding
Request Status])='Approved')"

if that bit works without error try
SELECT * FROM said:
(([AT&T Extended Price])=0)) "

Jeanette Cunningham

Ayo said:
Neither worked. The problem seem to be centered around this section WHERE
((([Extended Price])<>0) AND (([Funding Request Status])="Approved") AND
(([AT&T Extended Price])=0)) AND [Project Number]=062G4311 AND [Task
Number]=3000
IAnd I can't figure out what the missing operator is.


Jeanette Cunningham said:
Ayo,
the bit that is wrong is the quotes around Approved.
try
'Approved'

or

""Approved""

Jeanette Cunninghan


Ayo said:
I keep getting a syntax error (missing operator) message and I can't
figure
out what is wrong.

"SELECT * FROM [InScope Table] WHERE ((([Extended Price])<>0) AND
(([Funding
Request Status])="Approved") AND (([AT&T Extended Price])=0)) AND
[Project
Number]=062G4311 AND [Task Number]=3000"
 
B

BruceM

I'm not going to claim any great expertise with SQL, but I have noted that
there are parentheses here:
AND (([Funding Request Status])='Approved')
but not here:
AND [Project Number]='062G4311'
It looks to me from the double parentheses as if this statement was the end
of the SQL:
AND (([AT&T Extended Price])=0))
and then you added two more conditions, but after the double parentheses.
These observations are on top of those already mentioned about text fields
in quotes.

Jeanette Cunningham said:
Perhaps the Task number is a text field also?

Try "SELECT * FROM [InScope Table] WHERE [Extended Price]<>0"

if that bit works without the error then try
"SELECT * FROM [InScope Table] WHERE [Extended Price]<>0 AND (([Funding
Request Status])='Approved')"

if that bit works without error try
SELECT * FROM said:
(([AT&T Extended Price])=0)) "

Jeanette Cunningham

Ayo said:
Neither worked. The problem seem to be centered around this section WHERE
((([Extended Price])<>0) AND (([Funding Request Status])="Approved") AND
(([AT&T Extended Price])=0)) AND [Project Number]=062G4311 AND [Task
Number]=3000
IAnd I can't figure out what the missing operator is.


Jeanette Cunningham said:
Ayo,
the bit that is wrong is the quotes around Approved.
try
'Approved'

or

""Approved""

Jeanette Cunninghan


I keep getting a syntax error (missing operator) message and I can't
figure
out what is wrong.

"SELECT * FROM [InScope Table] WHERE ((([Extended Price])<>0) AND
(([Funding
Request Status])="Approved") AND (([AT&T Extended Price])=0)) AND
[Project
Number]=062G4311 AND [Task Number]=3000"
 

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

Top