【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

相关推荐
愚润求学12 小时前
【动态规划】01背包问题
c++·算法·leetcode·动态规划
dying_man15 小时前
LeetCode--44.通配符匹配
算法·leetcode
Paper Clouds16 小时前
代码随想录|图论|15并查集理论基础
数据结构·算法·leetcode·深度优先·图论
GGBondlctrl17 小时前
【leetcode】字符串,链表的进位加法与乘法
算法·leetcode·链表·字符串相加·链表相加·字符串相乘
打野二师兄18 小时前
LeetCode经典题解:21、合并两个有序链表
算法·leetcode·链表
前端拿破轮18 小时前
腾讯面试官:听说你在字节面试用栈实现队列,那怎么用队列实现栈呢?
算法·leetcode·面试
Y1nhl1 天前
力扣_二叉树的BFS_python版本
python·算法·leetcode·职场和发展·宽度优先
Owen_Q1 天前
Leetcode百题斩-二分搜索
算法·leetcode·职场和发展
zstar-_2 天前
Claude code在Windows上的配置流程
笔记·算法·leetcode
??tobenewyorker2 天前
力扣打卡第23天 二叉搜索树中的众数
数据结构·算法·leetcode