Let's say I have two tables:
TabA
+-----+----+
|TabID|Send|
| 1| 5|
| 2| 8|
| 3| 12|
| 4| 16|
+-----+----+
TabB
+-----+--------+
|TabID|Recieved|
| 1| 17|
| 4| 3|
| 5| 2|
| 6| 8|
+-----+--------+
And I would like result like this:
+-----+----+--------+
|TabID|Send|Recieved|
| 1| 5| 17|
| 2| 8| 3|
| 3| 12| 0|
| 4| 16| 0|
| 5| 0| 2|
| 6| 0| 8|
+-----+----+--------+
I tried this:
SELECT
COALESCE(A.TabID,B.TabID) as TabID,
COALESCE(A.Send,0) as Send,
COALESCE(B.Recieved,0) as Recieved
FROM
TabA AS A
LEFT JOIN
TabB AS B
ON
B.TabID = A.TabID
But I got this:
+-----+----+--------+
|TabID|Send|Recieved|
| 1| 5| 17|
| 2| 8| 3|
| 3| 12| 0|
| 4| 16| 0|
+-----+----+--------+
I'm sure there is a solution in MySQL doc, but I don't know how is this operation called.