一列的SQL设置值等于同一表中另一列的SQL设置值 [英] SQL set values of one column equal to values of another column in the same table

查看:1706
本文介绍了一列的SQL设置值等于同一表中另一列的SQL设置值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含两个DATETIME列的表.

I have a table with two DATETIME columns.

其中之一永远不会为NULL,但其中之一有时为NULL.

One of them is never NULL, but one of them is sometimes NULL.

我需要编写一个查询,将B列的所有NULL行设置为等于A列中的值.

I need to write a query which will set all the NULL rows for column B equal to the values in column A.

我尝试了

I have tried this example but the SQL in the selected answer does not execute because MySQL Workbench doesn't seem to like the FROM in the UPDATE.

推荐答案

听起来像您在一张桌子上工作,类似这样:

Sounds like you're working in just one table so something like this:

update your_table
set B = A
where B is null

这篇关于一列的SQL设置值等于同一表中另一列的SQL设置值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆