【LeetCode】组合两个表(mysql)

题目

编写解决方案,报告 Person 表中每个人的姓、名、城市和州。如果 personId 的地址不在 Address 表中,则报告为 null 。

以 任意顺序 返回结果表。

结果格式如下所示。

select firstName ,lastName,city,state

from Person

left join Address

on Person.personId = Address.PersonId

这段SQL代码是用来从person表中选择firstNamelastNamecitystate字段,并与Address表进行左连接(left join)。左连接会返回所有的person记录,即使在Address表中没有匹配的记录。

具体方法参考:联表查询中的左联查询(left join )

https://blog.csdn.net/m0_67930426/article/details/134321937https://blog.csdn.net/m0_67930426/article/details/134321937

相关推荐
ゞ 正在缓冲99%…6 小时前
leetcode2826.将三个组排序
算法·leetcode·动态规划
微笑尅乐10 小时前
洗牌算法讲解——力扣384.打乱数组
算法·leetcode·职场和发展
天选之女wow10 小时前
【代码随想录算法训练营——Day48】单调栈——42.接雨水、84.柱状图中最大的矩形
算法·leetcode
仰泳的熊猫12 小时前
LeetCode:773. 滑动谜题
数据结构·c++·算法·leetcode
夏鹏今天学习了吗12 小时前
【LeetCode热题100(50/100)】岛屿数量
算法·leetcode·职场和发展
墨染点香12 小时前
LeetCode 刷题【134. 加油站】
算法·leetcode·职场和发展
Voyager_414 小时前
算法学习记录08——并归的应用(LeetCode[315])
学习·算法·leetcode
海梨花14 小时前
【力扣Hot100】刷题日记
算法·leetcode·1024程序员节
chonbw15 小时前
226.翻转二叉树
算法·leetcode
sprintzer17 小时前
10.16-10.25力扣计数刷题
算法·leetcode