Solved

Python mysql update error

Posted on 2015-02-22
1
192 Views
Last Modified: 2015-02-22
I am trying to update a table (customerorder) for columns CustomerID, DelDate,DelTime and TotalCost - in row where (in this example) Key OrderID = 323. The function 'UpdateCustomerOrderinfo' below is used within the action page which supports the input form.

The error message below indicates some subtle syntax code. Hopefully you might spot it.

Tks for any assistance

def UpdateCustomerOrderInfo(db,cursor):
      cursor.execute ("""
         UPDATE customerorder
         SET CustomerID=%s, DelDate=%s, DelTime=%s, TotalCost=%s
         HAVING OrderID=%s
      """, (CustomerID, DelDate, DelTime, TotalCost, OrderID)) 

Open in new window



rs.ProgrammingError: 1064 (42000): 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 'HAVING OrderID='423'' at line 3

Open in new window

0
Comment
Question by:jameskane
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 40623963
I think you need to use WHERE instead of HAVING.
0

Featured Post

Webinar: Security & Encryption in the MySQL world

Join Percona’s Solutions Engineer, Dimitri Vanoverbeke as he presents “Security and Encryption in the MySQL world” on Thursday, July 6, 2017 at 7:00 am PDT / 10:00 am EDT (UTC-7).

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

696 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