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
This sounds like a job for union:
select sender as id from <table_name>
union
select receiver as id from <table_name>
Note that union
will remove duplicates (use union all
if you want to keep duplicates).
SELECT DISTINCT a.iResult
FROM
(SELECT sender as iResult FROM tableName
UNION
SELECT receiver as iResult FROM tableName) a
ORDER BY iResult ASC
Returns
2
3
6
7
8
9
10
OR
SELECT GROUP_CONCAT(b.iResult)
(SELECT DISTINCT a.iResult
FROM
(SELECT sender as iResult FROM tableName
UNION
SELECT receiver as iResult FROM tableName) a
ORDER BY iResult ASC) b
returns
2,3,6,7,8,9,10