简体   繁体   中英

How can I have two user inputs in a MySQL python execution where WHERE condition is 1 user input and the updated VALUES are another?

I am trying to update a table on MySQL with user input on Python. I previously set the data successfully with.format and also previously successfully selected one row from MySQL with user input where order.ID=%s (orderNo) but now I can't find a way to do them both together without getting a SQL syntax error.

https://i.stack.imgur.com/MIP1A.png

So how do I Update my customer table and set the specified values that are user Inputted where the orders.ID = orderNo (another user input)

Thanks

You need to put some text inside the {} , like

"value1 is {value1} and value2 is {value2}".format(value1=variable1, value2=variable2)

in code editor

You can also use f before the string quote, like

f"value1 is {variable1} and value2 is {variable2}"

in code editor

Unfortunately, this way just works in >= python3.7

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