my code is like this
select * from a left join b on a.t = b.t
UNION
select * from a right join b on a.t = b.t;
my result is like this restult
I want the result like this result2
Would anyone help?
my table structures are:
table a:
t x
- -
A 1
B 2
C 3
Table B:
t y
- -
B 2
C 3
D 4
table_code:
CREATE TABLE `a` (
`t` varchar(1) NOT NULL,
`x` int(1) NOT NULL,
PRIMARY KEY (`t`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
INSERT INTO `a` VALUES ('A',1);
INSERT INTO `a` VALUES ('B',2);
INSERT INTO `a` VALUES ('C',3);
CREATE TABLE `b` (
`t` varchar(1) NOT NULL,
`y` int(1) NOT NULL,
PRIMARY KEY (`t`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
INSERT INTO `b` VALUES ('B',2);
INSERT INTO `b` VALUES ('C',3);
INSERT INTO `b` VALUES ('D',4);