【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

相关推荐
Scabbards_6 小时前
面试Leetcode - Heap 堆
java·leetcode·面试
ValhallaCoder9 小时前
Leetcode-hot100(2026.08.17)
python·算法·leetcode
青 春 记 忆13 小时前
LeetCode 104. 二叉树的最大深度|Python 解法详解
python·算法·leetcode
evans在进步16 小时前
LeetCode 198:打家劫舍——Java 动态规划详解
java·leetcode·动态规划
Nil20817 小时前
leetcode 234回文链表
算法·leetcode·链表
ZC跨境爬虫17 小时前
LeetCode 119. 杨辉三角 II(原地更新优化详解 + Java Python 实现)
java·python·leetcode
吃着火锅x唱着歌17 小时前
LeetCode 3597.分割字符串
算法·leetcode·职场和发展
Nil2081 天前
leetcode 160相交链表
算法·leetcode·链表
ZC跨境爬虫1 天前
LeetCode 108. 将有序数组转换为二叉搜索树(递归构建详解 + Java Python 实现)
java·python·leetcode
Tisfy1 天前
LeetCode 3090.每个字符最多出现两次的最长子字符串:二重循环 / 滑动窗口
算法·leetcode·字符串·题解·模拟·双指针·滑动窗口