Can we use bulk update query in golang

I have 1000 of records which need to be updated in mysql, is there any way to update all records at once.

Normally - yes. What do you want to update?

Thanks for the reply, Sibert, I want to update 2 column (A, B) in my table depending upon ( where condition ) Cloumn c =(some value), i am getting these value from list of json data, these data are in huge number say(1000 of records) (column A, B, C values). so i need to update these value at once in table using mysql and golang.

I think this can be done in MySQL by using something like CASE WHEN … THEN. But I need more real data.

What have you tried so far?

I tried to extract those 3 key which i need to update in mysql, and unmarshall json into structure, the column A,B,C are in map[string]interface{}, then in for loop of map in executing update query, (so for every data i got say column A,B,C) i am updating in mysql table.
If i use case when statement then how will i iterate over case statement?

This is Postgresql, but it should work with MySQL aswell AFAIK. You do not have to “iterate”. MySQL does it for you.

yes it is working in mysql but my json data which i am unmarshlling into structure is not fix, it is dynamic, some time i have 100 records and sometime i am having 50 records, so how will i write case statement in golang as dynamic.

i have to update two column cloumn A and cloumn B where column C is 123 (say as example) and in structure sometime i will get 10 records, sometime 100.

As long as there are some fixed rules to follow, the record numbers does not matter. SQL does not care how many records you have. And you can use two levels of case or more.!17/8c48e/3

Do you have more specific example?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.