Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[ODBC Microsoft Access Driver] Syntax error (missing operator) 2

Status
Not open for further replies.

CombatKing

Programmer
Jul 6, 2007
3
0
0
GB
Hello everyone,

I am having problems with a query - I have successfully connected a PHP front end to an Access database, but the following query keeps causing an issue:
Code:
SELECT * FROM fault WHERE Started != 'no' && Deferred = 'no' && Complete = 'no'

The error message is:
Code:
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Started != 'no' && Deferred = 'no' && Complete = 'no''.

The table "fault" exists, and the columns "Started", "Deferred" and "Complete" all exist within the "fault" table.

The query works fine when I send it to an equivalent MySQL database, so I'm also wondering if there is a key difference between MySQL and the version of SQL used by ODBC/Access?
 
Try:

SELECT * FROM fault WHERE Started != 'no' [red]AND[/red] Deferred = 'no' [red]AND[/red] Complete = 'no'

Max Hugen
Australia
 
In Access, the SQL would be something like:

[tt]SELECT * FROM fault WHERE Started = 'no' AND Deferred = 'no' AND Complete = 'no'[/tt]
 
Oh, missed something... the php operator != is <> in Access.

SELECT * FROM fault WHERE Started <> 'no' AND Deferred = 'no' AND Complete = 'no'

Max Hugen
Australia
 
Thank you maxhugen and Remou - I should have realised any MS version of any technology uses a syntax similar to VB instead of C.

I'll bear this in mind in future.

Thank you again for your help.
 
Actually, the syntax is similar to SQL, since it's, well, SQL.

It is your original SQL statement that is not ANSI compliant. The || operator in ANSI SQL is for concatenation.

 
Tip: if you're not quite up to speed on SQL syntax, try using the MS Access graphical Query builder, then switch to SQL view to see the syntax. :)

Max Hugen
Australia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top