Chinaunix首页 | 论坛 | 博客
  • 博客访问: 155944
  • 博文数量: 11
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 170
  • 用 户 组: 普通用户
  • 注册时间: 2020-07-22 17:26
个人简介

blender https://www.blender-3d.cn/ blender3D模型库

文章分类

全部博文(11)

文章存档

2020年(11)

我的朋友

分类: SQLServer

2020-08-23 15:50:25



点击(此处)折叠或打开

  1. DROP TABLE [dbo].[test_a]
  2. GO
  3. CREATE TABLE [dbo].[test_a] (
  4. [id] int NULL ,
  5. [name] nvarchar(255) NULL
  6. )
  7. GO
  8. /*
  9.  Records of test_a
  10. */
  11. INSERT INTO [dbo].[test_a] ([id], [name]) VALUES (N'1', N'蘋果')
  12. INSERT INTO [dbo].[test_a] ([id], [name]) VALUES (N'2', N'橘子')
  13. INSERT INTO [dbo].[test_a] ([id], [name]) VALUES (N'3', N'菠蘿')
  14. INSERT INTO [dbo].[test_a] ([id], [name]) VALUES (N'4', N'香蕉')
  15. INSERT INTO [dbo].[test_a] ([id], [name]) VALUES (N'5', N'西瓜')
  16. GO
  17. ———————————————————–
  18. DROP TABLE [dbo].[test_b]
  19. GO
  20. CREATE TABLE [dbo].[test_b] (
  21. [id] int NULL ,
  22. [name] nvarchar(255) NULL
  23. )
  24. GO
  25. /*
  26.  Records of test_b
  27. */
  28. INSERT INTO [dbo].[test_b] ([id], [name]) VALUES (N'1', N'梨子')
  29. INSERT INTO [dbo].[test_b] ([id], [name]) VALUES (N'2', N'蘋果')
  30. INSERT INTO [dbo].[test_b] ([id], [name]) VALUES (N'3', N'草莓')
  31. INSERT INTO [dbo].[test_b] ([id], [name]) VALUES (N'4', N'桃子')
  32. INSERT INTO [dbo].[test_b] ([id], [name]) VALUES (N'5', N'香蕉')
  33. GO

先建立一下资料
接下来各种JOIN都来一下

点击(此处)折叠或打开

  1. /* inner join */
  2. SELECT * FROM test_a INNER JOIN test_b ON test_a.name = test_b.name

  3. /* outer join */
  4. SELECT * FROM test_a left JOIN test_b ON test_a.name = test_b.name
  5. SELECT * FROM test_a left JOIN test_b ON test_a.name = test_b.name WHERE test_b.name IS NULL
  6. SELECT * FROM test_a right JOIN test_b ON test_a.name = test_b.name
  7. SELECT * FROM test_a right JOIN test_b ON test_a.name = test_b.name WHERE test_a.name IS NULL
  8. SELECT * FROM test_a FULL JOIN test_b ON test_a.name = test_b.name
  9. SELECT * FROM test_a FULL JOIN test_b ON test_a.name = test_b.name WHERE test_b.name IS NULL

  10. /* cross join 沒事不要下 */
  11. SELECT * FROM test_a cross JOIN test_b


阅读(3103) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~