Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 . . .
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
175 views
Welcome To Ask or Share your Answers For Others

1 Answer

You have to remove the comma from the last assignment:

Country10 = returnCountryName(Country,9),

See also my answer to your original question


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...