sql - SQL中连接的多列中的单列
问题描述
我有一个这样的表输出,这是多个表连接的结果。
+---------+------+--------+------+
| Id | V1 | V2 | V3 |
+---------+------+--------+------+
| 1 | x1 | null | null|
| 2 | x2 | null | null|
| 3 | null | x3 | null|
| 4 | null | x4 | null|
| 5 | null | null | x9 |
+---------+------+--------+------+
我想得到一张这样的桌子。
+---------+------+
| Id | V |
+---------+------+
| 1 | x1 |
| 2 | x2 |
| 3 | x3 |
| 4 | x4 |
| 5 | x5 |
+---------+------+
这就是我目前正在做的事情。不知道如何使三列合并为一列。
select a.identifier, a.v1, b.v2, c.v3,
from table a
full join table b on a.identifier = b.identifier
full join table c on a.identifier = c.identifier
where a.v REGEXP 'some condition'
解决方案
看看 - COALESCE() 函数,它返回列表中的第一个非空值。
推荐阅读
- c - 我无法理解 fgetc 的核心转储原因,我该如何解决?
- php - 弹出的进程永不消亡
- javascript - Promise 链接未处理的 Promise
- javascript - 在 ASP 页面中使用带有 Jquery 的 JS 函数
- python - 创建多边形的算法(No Thiesen/Voronoi)
- coldfusion - apache 已配置,但网站仍无法加载coldfusion
- python-3.x - 内核启动请等待 macbook air m1 上的 jupyter notebook
- python - 删除每一行的 NaN 后是否可以将每一行移动到同一行的末尾
- ms-access-2016 - 我想搜索一个字段,但使用部分文本来定位记录。代码现在可以找到记录,但我必须输入整个文本才能找到记录。使用权
- java - 使用 Oracle SQL 存储过程和 Java Spring 通过多行插入和提取提高性能