【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

相关推荐
Fanxt_Ja13 小时前
【LeetCode】算法详解#15 ---环形链表II
数据结构·算法·leetcode·链表
元亓亓亓15 小时前
LeetCode热题100--105. 从前序与中序遍历序列构造二叉树--中等
算法·leetcode·职场和发展
仙俊红18 小时前
LeetCode每日一题,20250914
算法·leetcode·职场和发展
_不会dp不改名_1 天前
leetcode_21 合并两个有序链表
算法·leetcode·链表
吃着火锅x唱着歌1 天前
LeetCode 3302.字典序最小的合法序列
leetcode
睡不醒的kun1 天前
leetcode算法刷题的第三十四天
数据结构·c++·算法·leetcode·职场和发展·贪心算法·动态规划
吃着火锅x唱着歌1 天前
LeetCode 978.最长湍流子数组
数据结构·算法·leetcode
爱编程的化学家1 天前
代码随想录算法训练营第十一天--二叉树2 || 226.翻转二叉树 / 101.对称二叉树 / 104.二叉树的最大深度 / 111.二叉树的最小深度
数据结构·c++·算法·leetcode·二叉树·代码随想录
吃着火锅x唱着歌1 天前
LeetCode 1446.连续字符
算法·leetcode·职场和发展
愚润求学1 天前
【贪心算法】day10
c++·算法·leetcode·贪心算法