+ Reply to Thread
Results 1 to 9 of 9

Syntax error (missing operator) when UPDATE in ODBC SQL

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Syntax error (missing operator) when UPDATE in ODBC SQL

    I know I am still learning SQL but I have run into a problem with an UPDATE query.

    I have tried a few different variants of the query but I keep getting error messages similar to "-2147217900 [Microsoft][ODBC Excel Driver] Syntax error (missing operator) in query expression"

    What do I do?

    (I tried posting all of the failed SQL queries but when I did, Excel Forums security kicked me out and I lost several minutes of typing )


    Attempt #1

    Query
    Please Login or Register  to view this content.
    Error Message
    Please Login or Register  to view this content.
    Attempt #2

    Query
    Blocked. SUCURI CLOUD PROXY = "SQL injection was detected and blocked."

    Error Message
    Please Login or Register  to view this content.

    Attempt #3

    Query
    Blocked. SUCURI CLOUD PROXY = "SQL injection was detected and blocked."

    Error Message
    Please Login or Register  to view this content.
    Last edited by mc84excel; 07-01-2015 at 11:29 PM.
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Syntax error (missing operator) when UPDATE in ODBC SQL

    Attempt 1 is the closest, the other 2 are TSQL which I doubt will work on an excel file. Firstly, you don't need a from clause, you only have one table, secondly you do not need the "is not null" something cannot be null if it's false. Finally, drop the parentheses, they're superflous and not helpful when error hunting

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Syntax error (missing operator) when UPDATE in ODBC SQL

    Please Login or Register  to view this content.
    If you arn't using excel as your data source, then you need to tell us which db you're using

  4. #4
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Syntax error (missing operator) when UPDATE in ODBC SQL

    Quote Originally Posted by Kyle123 View Post
    Attempt 1 is the closest, the other 2 are TSQL which I doubt will work on an excel file. Firstly, you don't need a from clause, you only have one table
    Thanks for that, I didn't know. I thought you always had to use FROM for any select/update/insert query!

    Quote Originally Posted by Kyle123 View Post
    secondly you do not need the "is not null" something cannot be null if it's false.
    I can explain that one! The first attempt I posted wasn't really my first attempt. The 'IsDependent' can contain True, False or Null and I was hoping to do update InclHeader in one hit. After getting nowhere, I decided to focus on updating the False first. Hence the 'is not null' artifact in the 1st query I posted.

    Quote Originally Posted by Kyle123 View Post
    Finally, drop the parentheses, they're superflous and not helpful when error hunting
    This is refreshing advice! My teachers were strong on parentheses you see; and since then I have started guiltily dropping them when I build queries with multiple joins (I find it much easier to omit them in the FROM section in case I want to add another table to the query)

  5. #5
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Syntax error (missing operator) when UPDATE in ODBC SQL

    Quote Originally Posted by Kyle123 View Post
    Please Login or Register  to view this content.
    If you arn't using excel as your data source, then you need to tell us which db you're using
    Hi Kyle, Thanks for posting the query to try but I'm afraid I can't get it to work. Instead I am now getting an error message "-2147217913 [Microsoft][ODBC Excel Driver] Data type mismatch in criteria expression."?

    Would it be easier if I provided a test copy of my data source? See attached. (I have removed a few columns & sheets for privacy reasons - but their removal shouldn't affect the update query)
    Last edited by mc84excel; 07-08-2015 at 08:12 PM. Reason: removed attachment for privacy

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Syntax error (missing operator) when UPDATE in ODBC SQL

    I'm on holiday, so don't have a laptop, so not really

    If your fields are booleans then your true and false don't need to be strings - try just including as true/false

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Syntax error (missing operator) when UPDATE in ODBC SQL

    Parenthesis are like anything, just use them where they're necessary, I suspect that your teachers keenness on them is due to access having a really strange syntax where multiple joins must be enclosed and won't work without doing so- afaik this only applies to access though

  8. #8
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Syntax error (missing operator) when UPDATE in ODBC SQL

    Quote Originally Posted by Kyle123 View Post
    Parenthesis are like anything, just use them where they're necessary, I suspect that your teachers keenness on them is due to access having a really strange syntax where multiple joins must be enclosed and won't work without doing so- afaik this only applies to access though
    Kyle, I suspect you are right - on both counts. The teacher taught classes on MS Access as well as SQL. And I have used unenclosed multiple joins on SQL Server and on ODBC/Excel without any problems.

  9. #9
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Syntax error (missing operator) when UPDATE in ODBC SQL

    Quote Originally Posted by Kyle123 View Post
    If your fields are booleans then your true and false don't need to be strings - try just including as true/false
    Hooray! The combination of this post & your previous post (#3) was the answer!

    Please Login or Register  to view this content.
    This problem was really frustrating me. Thank you Kyle and enjoy your holiday! +1

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Syntax error (Missing operator) in query expression
    By lengwer in forum Access Tables & Databases
    Replies: 2
    Last Post: 08-22-2013, 04:00 PM
  2. [SOLVED] Help running SQL Update Via VBA (Missing Operator Debug Error)
    By jo15765 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-22-2012, 09:15 AM
  3. Syntax Error (missing Operator) in query expression
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-25-2011, 11:59 AM
  4. missing operator error
    By Jollyfrog in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-28-2010, 09:13 AM
  5. [SOLVED] Syntax error (missing operator) in query expression '6 Wescott Rd#
    By shealy in forum Excel General
    Replies: 0
    Last Post: 06-09-2005, 05:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1