从同一列获取2个值以显示在同一结果中

时间:2017-01-06 09:56:46

标签: sql

我的表格看起来像这样

PlayerID    PlayerName    Score
1           koates        0
2           tberckley      0
3           testAcc       3

我想得到玩家的名字:koates和testAcc作为结果显示但是我写的内容显示了两个结果,但是单独的结果。

SELECT * FROM Players WHERE PlayerName='koates'
SELECT * FROM Players WHERE PlayerName='testAcc'

我正在为游戏制作一个简单的登录页面,它会查找此人输入的用户名

2 个答案:

答案 0 :(得分:4)

您正在寻找IN将两者结合起来:

select *
from Players
where PlayerName in ('koates', 'testAcc');

答案 1 :(得分:0)

示例查询:

select Result from
(
    select 'PlayerName' as Result from [Yourtablename]
    union
    select 'Score' as Result from [Yourtablename]
)tt 
   where Result is not null;