Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

You have an error in your SQL syntax

Posted on 2007-11-24
4
Medium Priority
?
206 Views
Last Modified: 2010-03-20
I moved my database from Access to MySQL. I then installed ODBC 3.51 driver for MySQL.

I'm getting the following error:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[MySQL][ODBC 3.51 Driver][mysqld-5.0.45-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[Student Number] = 'Student Number' AND Not [Student Number] = '') OR ([Student ' at line 1
/aspDump/uploader.asp, line 173

The query its referring to is:

query2 = "SELECT * FROM webctgrades WHERE (([Student Number] = '" & records(3) & "' AND Not [Student Number] = '') OR ([Student ID] = '" & records(2) & "' AND NOT [Student ID] = '')) And Record = '2' And [Course Number] = '" & courseNum & "'"

I've checked the fieldnames and table name and all appear to be identical.

Any help would be seriously appreciated.
0
Comment
Question by:ben_stilwell
  • 2
4 Comments
 
LVL 44

Expert Comment

by:GRayL
ID: 20343282
Isn't the concatenation operator for SQL the plus sign instead of the ampersand?
0
 

Author Comment

by:ben_stilwell
ID: 20343295
Still has the same error. I should have mention that this is a query being called from ASP, the ampersands would be used there, but the query as it is executed shouldn't contain them.
0
 
LVL 20

Accepted Solution

by:
steelseth12 earned 500 total points
ID: 20343302
[Student Number] should be `Student Number`
[Student ID] should be `Student ID`
[Course Number] should be `Course Number`

Im not familiar with access but in mysql you need to use backticks ``
0
 

Author Comment

by:ben_stilwell
ID: 20343315
Yep that was it. I knew it was something small.

Thanks.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question