mysql - 从 3 个不同的列中选择不同的记录
问题描述
我有这样的场景。
有 3 个不同的列。用户 ID、硬币和钱包。如果特定用户有任何硬币和钱包,我只想选择不同的硬币和钱包。我怎样才能做到这一点。在下图中,您可以看到我目前拥有的和想要的。我为此尝试使用子查询,但由于某种原因,它似乎无法正常工作。
解决方案
您可以尝试使用联合
select userid, coin as asset from tablename where coin is not null
union
select userid, wallet from tablename where wallet is not null
推荐阅读
- csv - ArangoDB:如何将集合导出到 CSV?
- colors - vs代码中的文本颜色
- c - 如何用 LuaJIT 定义 C 函数?
- protobuf-c - 通过 vcpkg 安装旧版本的 protobuf
- tableau-api - 如何在 Tableau 中为轴刻度使用范围而不是单个值?
- mysql - 从 SQL 中输入的日期查找最近的日期,两种方式
- javascript - 如何选择()元素背景颜色?
- c# - 如何将数字从十进制传送到整个字节数组
- bash - 如何重新运行脚本?
- angular - ViewEncapsulation.ShadowDom 与 ViewEncapsulation.Native