从3个不同的列中选择不同的记录

时间:2018-11-30 06:10:33

标签: mysql codeigniter mysqli subquery codeigniter-3

我有这样的情况。

enter image description here

共有3个不同的列。 UserId,硬币和钱包。如果特定用户有硬币和钱包,我只想选择不同的硬币和钱包。我该如何实现。在下图中,您可以看到我目前拥有的东西和想要的东西。为此,我尝试使用子查询,但由于某种原因,它似乎无法正常工作。

1 个答案:

答案 0 :(得分:1)

您可以尝试使用工会

select userid, coin as asset from tablename where coin is not null
union 
select userid, wallet from tablename where wallet is not null
相关问题