The below query is to update a field that is set to null in a config table from records that contain values in the same table.
I came across this scenario while working on a puppet upgrade project where we are moving the file based Yaml configs to SQL DB.
below is the query:
The table contains some "groupname" fields that contains null, still those should contain same group values as others given that name field is the same.
the above query will do that for us.
Not that the above query will not run in MySQL !!
Thanks to my friend Mohamed Youssef who helped me with this query.
I came across this scenario while working on a puppet upgrade project where we are moving the file based Yaml configs to SQL DB.
below is the query:
update config_dev cset groupname = l.groupnamefrom ( select distinct (groupname) , name from config_dev where groupname is not null ) lwhere c.groupname is nulland c.name = l.nameThe table contains some "groupname" fields that contains null, still those should contain same group values as others given that name field is the same.
the above query will do that for us.
Not that the above query will not run in MySQL !!
Thanks to my friend Mohamed Youssef who helped me with this query.

No comments:
Post a Comment