广告
返回顶部
首页 > 资讯 > 数据库 >数据库左连接、右连接、全联接、左外、右外、全外
  • 163
分享到

数据库左连接、右连接、全联接、左外、右外、全外

2024-04-02 19:04:59 163人浏览 八月长安
摘要

内联 SELECT*FROMtemployee employees0INNER JOIN tcustomer customer1 ON ( customer1.id = employees0.id

数据库左连接、右连接、全联接、左外、右外、全外

内联

数据库左连接、右连接、全联接、左外、右外、全外
数据库左连接、右连接、全联接、左外、右外、全外
SELECT
*
FROM
temployee employees0
INNER JOIN tcustomer customer1 ON ( customer1.id = employees0.id );

左联

数据库左连接、右连接、全联接、左外、右外、全外
数据库左连接、右连接、全联接、左外、右外、全外
SELECT
*
FROM
temployee employees0
LEFT OUTER JOIN tcustomer customer1 ON ( customer1.id = employees0.id );

右联

数据库左连接、右连接、全联接、左外、右外、全外
数据库左连接、右连接、全联接、左外、右外、全外
SELECT
*
FROM
temployee employees0
RIGHT OUTER JOIN tcustomer customer1 ON ( customer1.id = employees0.id );

全联=左联+右联(Mysql不支持)

数据库左连接、右连接、全联接、左外、右外、全外
SELECT * FROM t_employee te FULL JOIN t_customer tc ON (te.id = tc.id);

左外

数据库左连接、右连接、全联接、左外、右外、全外
数据库左连接、右连接、全联接、左外、右外、全外
SELECT
*
FROM
temployee employees0
LEFT OUTER JOIN tcustomer customer1 ON ( customer1.id = employees0.id )
WHERE
customer1_.id IS NULL;

右外

数据库左连接、右连接、全联接、左外、右外、全外
数据库左连接、右连接、全联接、左外、右外、全外
SELECT *
FROM
temployee employees0
RIGHT OUTER JOIN tcustomer customer1 ON ( customer1.id = employees0.id )
WHERE
employees0_.id IS NULL;

全外=左外+右外(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;

数据库

Employee
数据库左连接、右连接、全联接、左外、右外、全外
Customer
数据库左连接、右连接、全联接、左外、右外、全外

-- ----------------------------
-- Table structure for t_employee
-- ----------------------------
DROP TABLE IF EXISTS `t_employee`;
CREATE TABLE `t_employee` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `employee_name` varchar(255) DEFAULT NULL,
  `employee_part` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of t_employee
-- ----------------------------
INSERT INTO `t_employee` VALUES (1, '老潘', '总裁部');
INSERT INTO `t_employee` VALUES (2, '老王', '秘书部');
INSERT INTO `t_employee` VALUES (3, '老张', '设计部');
INSERT INTO `t_employee` VALUES (4, '老李', '运营部');

-- ----------------------------
-- Table structure for t_customer
-- ----------------------------
DROP TABLE IF EXISTS `t_customer`;
CREATE TABLE `t_customer` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `customer_name` varchar(255) DEFAULT NULL,
  `customer_part` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of t_customer
-- ----------------------------
INSERT INTO `t_customer` VALUES (2, '老王', '秘书部');
INSERT INTO `t_customer` VALUES (3, '老张', '设计部');
INSERT INTO `t_customer` VALUES (4, '老刘', '人事部');
INSERT INTO `t_customer` VALUES (5, '老黄', '生产部');
您可能感兴趣的文档:

--结束END--

本文标题: 数据库左连接、右连接、全联接、左外、右外、全外

本文链接: https://www.lsjlt.com/news/39003.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作