LeeCode——Combine Two Tables
Table: Person
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| PersonId | int |
| FirstName | varchar |
| LastName | varchar |
+-------------+---------+
PersonId is the primary key column for this table.
Table: Address
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| AddressId | int |
| PersonId | int |
| City | varchar |
| State | varchar |
+-------------+---------+
AddressId is the primary key column for this table.
Write a SQL query for a report that provides the following information for each person in the Person table, regardless if there is an address for each of those people:
FirstName, LastName, City, State
解题思路较为简单,使用left join即可解决.
答案如下图所示:
# Write your MySQL query statement below
select Person.FirstName, Person.LastName, Address.City, Address.State from Person left join Address on Person.PersonId = Address.PersonId;
PS:
如果您觉得我的文章对您有帮助,请关注我的微信公众号,谢谢!
LeeCode——Combine Two Tables的更多相关文章
- LeetCode 175 Combine Two Tables mysql,left join 难度:0
https://leetcode.com/problems/combine-two-tables/ Combine Two Tables Table: Person +-------------+-- ...
- LeetCode 175. Combine Two Tables 【MySQL中连接查询on和where的区别】
一.题目 175. Combine Two Tables 二.分析 连接查询的时候要考虑where和on的区别 where : 查询时,连接的时候是必须严格满足条件的,满足了才会加入到临时表中. on ...
- LeeCode(Database)-Combine Two Tables
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
- [Leetcode|SQL] Combine Two Tables
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
- [LeetCode] Combine Two Tables 联合两表
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
- [leetcode]Combine Two Tables
leetcode竟然有sql的题了..两道简单的应该会做 这个题主要就是一个left join... # Write your MySQL query statement below SELECT P ...
- Leetcode 175. Combine Two Tables
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
- Combine Two Tables
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
- 175. Combine Two Tables【LeetCode】-LEFT JON 和RIGHT JOIN,两张表关联查询-java -sql入门
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
随机推荐
- Vue.js+cube-ui(Scroll组件)实现类似头条效果的横向滚动导航条
本博主在一次个人移动端项目中,遇到这么一个需求:希望自己的项目中,头部导航条的效果可以像今日头条那样,横向滚动! 对于这样的效果,在各大移动端项目中几乎是随处可见,为什么呢? 我们都知道,对于移动端也 ...
- 使用 shopfiy 模板语言,创建产品模板以搭配购物车实现一键购买
shopfiy 的 product 在添加产品时,如果要将产品详情页面与购物车关联,就是在详情页里面直接下单,而不是从详情页通过点击购买按钮,跳到 shopfy stroe ,再从这个位置再跳转到下单 ...
- 渗透测试学习 二十一、 JSP相关漏洞
大纲 ST2漏洞 (Struts2) 反序列漏洞 网站容器,中间键 其他漏洞 Struts2漏洞 简介: Struts2是一个基于MVC设计模式的Web应用框架,它本质上相 ...
- Linux:路径的概念及路径的切换
路径分为绝对路径和相对路径 绝对路径:从/根开头的路径为绝对路径 相对路径:以当前目录为开头的为相对路径 根目录:/ 家目录:普通用户的家目录在/home下,root用户的家目录是/root 切换目录 ...
- CodeForces-1257D (贪心+双指针)
题意 https://vjudge.net/problem/CodeForces-1257D 你需要操作m个英雄去打败n只怪物,每个英雄的力量值为pi,可以打败si只怪物:每只怪物的力量值为ai. 当 ...
- WebUI自动化测试框架
基于Python+Selenium+Unittest+Ddt+HTMLReport 框架结构: Business:业务相关公共模块,如登录 Common:业务无关公共模块,如读取文件 PageObje ...
- 5.Java基础_Java算术/字符/字符串/赋值运算符
/* 算术/字符/字符串/赋值 运算符 */ public class OperatorDemo01 { public static void main(String[] args){ //算术运算符 ...
- RabbitMQ学习笔记(一、消息中间件基础)
目录: 什么是消息中间件 消息中间件的作用 JMS规范 AMQP协议 RabbitMQ简介 Hello World 什么是消息中间件: 消息中间件(Message Queue Middleware,简 ...
- 201871010102-常龙龙《面向对象程序设计(java)》第十一周学习总结
项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.com/nwnu-daizh/p ...
- O2O 线下业务 和 线上业务,在特征工程上的差异
人工智能在外卖送达时预估上的应用 这篇讲清楚了 O2O 线下业务 和 线上业务,在特征工程上的差异:
