sql - 更新返回 * 并选择结果作为行
问题描述
我想在返回 * 的单个查询中运行一些更新,并将输出选择为行。我目前有
with
foo as (update table set .. where id = $1 retuning *),
bar as (update table set .. where id = $2 retuning *)
select * from table where id = $1 or id = $2;
这正是我想要的,但感觉它可以改进。我几乎让它像这样工作
select * from foo, bar
但它显示为单行而不是两个单独的行
解决方案
我认为您只是想要union all
(或者可能是`union1):
select foo.*
from foo
union all
select bar.*
from bar;
推荐阅读
- html - 使粘性表格标题行完全不透明
- reactjs - 如何测试具有片段的功能组件?
- php - 如何在 Smarty 脚本中将表达式分配给变量并检查它是奇数还是偶数
- python - 如何将 Flask connexion 与 redis 一起使用?
- javascript - 任何气泡地球地图文本颜色变化
- javascript - 我使用我制作的网站制作了一个 webview 应用程序,但奇怪的是,该应用程序的某些部分不起作用
- kotlin - 将多个 Mime 类型传递给 ActivityResultLauncher.launch()
- linux - 从 bash 将文件上传到谷歌驱动器
- mule-component - Munit 2.2.1 在 Mule 运行时 4.3.0 中不工作
- javascript - 目标入口点“@angular/elements”中的错误缺少依赖项: