Get the App
SLTechnology News&Howtos  ›  Database  › 

Database left connection, right connection, full connection, left outer, right outer, full outer

Shulou Source: shulou.com Published: 2022-06-01 14:59:23 10月02日 Update

Inline

SELECT

*

FROM

Temployee employees0

INNER JOIN tcustomer customer1 ON (customer1.id = employees0.id)

Left couplet

SELECT

*

FROM

Temployee employees0

LEFT OUTER JOIN tcustomer customer1 ON (customer1.id = employees0.id)

Right couplet

SELECT

*

FROM

Temployee employees0

RIGHT OUTER JOIN tcustomer customer1 ON (customer1.id = employees0.id)

Quanlian = left + right (not supported by MySql)

SELECT * FROM t_employee te FULL JOIN t_customer tc ON (te.id = tc.id)

Left outside

SELECT

*

FROM

Temployee employees0

LEFT OUTER JOIN tcustomer customer1 ON (customer1.id = employees0.id)

WHERE

Customer1_.id IS NULL

Right outside

SELECT *

FROM

Temployee employees0

RIGHT OUTER JOIN tcustomer customer1 ON (customer1.id = employees0.id)

WHERE

Employees0_.id IS NULL

Full outside = left outside + right outside (not supported by MySql)

SELECT *

FROM

T_employee te

FULL JOIN t_customer tc ON (te.id = tc.id)

WHERE

Te.id IS NULL

OR tc.id IS NULL

Database

Employee

Customer

-Table structure for tweak employeeWhile-DROP TABLE IF EXISTS `t _ employee` CREATE TABLE `t _ employee` (`id` bigint (20) NOT NULL AUTO_INCREMENT, `employee_ name` varchar (255i) DEFAULT NULL, `employee_ part` varchar (255i) DEFAULT NULL, PRIMARY KEY (`id`) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci -Records of tweak employee VALUES-- INSERT INTO `t _ employee` VALUES (1, 'Lao Pan', 'Chief Adjudication Department'); INSERT INTO `t _ employee` VALUES (2, 'Lao Wang', 'Secretary Department') INSERT INTO `t _ employee`VALUES (3, 'Lao Zhang', 'Design Department'); INSERT INTO `t _ employee` VALUES (4, 'Lao Li', 'Operation Department');-Table structure for tasking customerCustom-- DROP TABLE IF EXISTS `tcustomer` CREATE TABLE `tcustomer` (`id` bigint (20) NOT NULL AUTO_INCREMENT, `customer_ name` varchar (255i) DEFAULT NULL, `customer_ part` varchar (255DEFAULT NULL), PRIMARY KEY (`id`) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci -Records of tasking customerCustom-INSERT INTO `tcustomer` VALUES (2, 'Lao Wang', 'Secretary Department'); INSERT INTO `tcustomer` VALUES (3, 'Lao Zhang', 'Design Department') INSERT INTO `tcustomer` VALUES (4, 'Lao Liu', 'personnel Department'); INSERT INTO `tcustomer` VALUES (5, 'Lao Huang', 'production Department')

Tags: Secretary Lao Zhang Lao Wang Design Department support Design data Database personnel President Operation Department Lao Liu Lao Li personnel Department production Department Lao Huang production Operation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MySQL MariaDB NVidia OPPO Reno