开发者

MySQL selecting distinct names from two columns

I have two columns of coaches names:

coach1
JOHN
JACOB
MARY

coach2
JOHN
JAC开发者_运维问答OB
HENRY

I would like to select all DISTINCT values between the two columns.

So that my SELECT statement will read,

JOHN
JACOB
MARY
HENRY

with no duplicates. Any suggestions as to the most efficient way to do this?


SELECT COACH1 AS NAME FROM TABLE
UNION
SELECT COACH2 AS NAME FROM TABLE

Is a way to do. I'm not saying it's the "most" efficient to do, though :) Shouldn't be too bad. UNION by default will select only distinct values.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜