Home > Back-end >  sql query to move values from second_names column to firstn_name column when first_name column is nu
sql query to move values from second_names column to firstn_name column when first_name column is nu

Time:11-11

below is my requirement

i need to push second_name values to first_name column only when first_name columns are null.

for example,

i want drake and jim to be moved to first_name column and should not be present in second_name column.Rest of the names should be same as it is.

enter image description here

CodePudding user response:

Looks like

update your_table set
  first_name  = second_name,
  second_name = null
where first_name is null;
  • Related