简体   繁体   中英

SELECT Statement - Syntax error in query expression ' '

Trying to SELECT a row in my excel file. I'm using it as a database. I'm pretty sure the problem is either in my query or in my excel file.

SELECT * FROM [tableName$] where _columnNum1 = 'testData123'"

I've tried doing this code for a while

SELECT * FROM [tableName$]

and it worked. So every time I add a WHERE clause, it causes the error. What seems to be the problem here?

The error says Syntax error in query expression '_columnNum1 = 'testData123''

UPDATE: I forgot to add this, I've already googled this thing for some time now, and the error is about data types. But since I'm using excel as a database, I can't really manipulate data types around them. Or can I? Anyway maybe the error is about data types.

After hours of searching, finally got the answer. I simply added brackets on the column name. I didn't need them when I was inserting data in my excel file.

I have the string sql of

SELECT * FROM [tableName$] where _columnNum1 = 'testData123'"

when it should be

SELECT * FROM [tableName$] where [_columnNum1] = 'testData123'"

I got the answer here:

SOURCE: OLE CALL to Excel with WHERE clause

Another note, for people who has trouble inserting data in their excel where the data does not go to the first row, the source might be the answer, too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM