I want to update a series of columns Country1, Country2... Country 9 based on a comma delimited string of country names in column Country. I've programmed a single statement to accomplish this task.
cur.execute("\
UPDATE t \
SET Country1 = returnCountryName(Country,0),\
Country2 = returnCountryName(Country,1),\
Country3 = returnCountryName(Country,2),\
Country4 = returnCountryName(Country,3),\
Country5 = returnCountryName(Country,4),\
Country6 = returnCountryName(Country,5),\
Country7 = returnCountryName(Country,6),\
Country8 = returnCountryName(Country,7),\
Country9 = returnCountryName(Country,8),\
Country10 = returnCountryName(Country,9),\
WHERE Country IS NOT NULL\
;")
Howerver, I am getting the error
sqlite3.OperationalError: near "WHERE": syntax error
Press any key to continue . . .
You have to remove the comma from the last assignment:
Country10 = returnCountryName(Country,9),\
See also my answer to your original question
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.