mysql query unite 2 columns

前端 未结 2 1163
野的像风
野的像风 2021-01-28 04:37

I have a table friends with 4 columns (id, sender, receiver, status) and I need a query that will unite (reunion, I dont know the word in english) the sender and receiver colums

2条回答
  •  臣服心动
    2021-01-28 04:49

    This sounds like a job for union:

    select sender as id from 
    union
    select receiver as id from 
    

    Note that union will remove duplicates (use union all if you want to keep duplicates).

提交回复
热议问题