简体   繁体   English

当 first_name 列为空时,sql 查询将值从 second_names 列移动到 firstn_name 列

[英]sql query to move values from second_names column to firstn_name column when first_name column is null

below is my requirement下面是我的要求

i need to push second_name values to first_name column only when first_name columns are null.仅当 first_name 列为空时,我才需要将 second_name 值推送到 first_name 列。

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.我希望将 drake 和 jim 移至 first_name 列,并且不应出现在 second_name 列中。其余名称应保持原样。

在此处输入图片说明

Looks like好像

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 什么 T-SQL 查询会检索 Email 列的所有值,其中 First_Name 和 Last_ Name 列的值位于 Email 列中? - What T-SQL query would retrieve all values of the Email column where values of First_Name and Last_ Name columns are in the Email column? 将 first_name 和 last_name 列中的名称截断为 1 个字符的最有效方法是什么? - What's the most efficient way of truncating the names in a first_name and last_name column to 1 character? SQL 具有相同第一列的查询,在第二列中包含两个值 - SQL Query with same first column, contains two values in the second column 不能将“MAX(CASE WHEN value ='first_name' THEN value END) 中的列 label 值用作'Förnamn' - Cant use column label value in "MAX(CASE WHEN value ='first_name' THEN value END) as 'Förnamn' 带有列名和第一行值的 Sql 映射 - Sql mapping with column name and first row values 从任何“SQL 查询”字符串中提取列名和表名 - extract column names and table name from any “SQL query” String SQL 将一些列名转换为行值,将一个列名行值转换为列名 - SQL convert some column names to row values and one column name row values to column name 当表名在第一个表的列数据中时,如何从第二个表查询数据 - How to query data from a second table when the table's name is in first table's column data 你能为重组目的给SQL列名称一个“第二个名字”吗? - Can you give SQL Column names a 'second name' for refactoring purposes? Sql查询获取名称列为null - Sql query getting name column null
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM