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

查询person表中的每个人的地址信息,不管这些人是否有一个地址

MySQL(1128ms):
 # Write your MySQL query statement below
SELECT FirstName , LastName , City , State
FROM Person LEFT JOIN Address
ON Person.PersonId = Address.PersonId ;
 

175. Combine Two Tables的更多相关文章

  1. LeetCode 175. Combine Two Tables 【MySQL中连接查询on和where的区别】

    一.题目 175. Combine Two Tables 二.分析 连接查询的时候要考虑where和on的区别 where : 查询时,连接的时候是必须严格满足条件的,满足了才会加入到临时表中. on ...

  2. LeetCode 175 Combine Two Tables mysql,left join 难度:0

    https://leetcode.com/problems/combine-two-tables/ Combine Two Tables Table: Person +-------------+-- ...

  3. Leetcode 175. Combine Two Tables

    Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...

  4. 175. Combine Two Tables【LeetCode】-LEFT JON 和RIGHT JOIN,两张表关联查询-java -sql入门

    Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...

  5. leetcdoe 175. Combine Two Tables

    给定两个表,一个是人,一个是地址,要求查询所有人,可以没有地址. select a.FirstName, a.LastName, b.City, b.State from Person as a le ...

  6. 【SQL】175. Combine Two Tables

    Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...

  7. leetcode 175 Combine Two Tables join用法

    https://leetcode.com/problemset/database/ ACM退役,刚好要学sql,一定要刷题才行,leetcode吧. 这一题,说了两个表,一个左一个右吧,左边的pers ...

  8. LeetCode 175. Combine Two Tables (组合两个表)

    题目标签: 题目给了我们两个table,让我们合并,根据Person为主. 因为题目说了 提供person 信息,不管这个人有没有地址.所以这里用Left Join. Java Solution: R ...

  9. [Leetcode|SQL] Combine Two Tables

    Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...

随机推荐

  1. jq的each理解

    1种 通过each遍历li 可以获得所有li的内容 <!-- 1种 --> <ul class="one"> <li>11a</li> ...

  2. 第三方库安装——requests

    环境 操作系统:CentOS 6.7 32-bit Python:2.6.6 安装 pip install requests

  3. ACE反应器(Reactor)模式(3)

    转载于:http://www.cnblogs.com/TianFang/archive/2006/12/18/595938.html 在服务器端使用Reactor框架 使用Reactor框架的服务器端 ...

  4. webstorm常用功能快捷方式

    1 自动注释和撤销注释:ctrl+/ 在一句代码前面用 ctrl+/ 可以自动注释和撤销注释,js,html都可以,很好的省去了敲注释符的时间 (mac下为command+/,下同) 2 自动补全ht ...

  5. js随机数生成与排序

    'use strict'; // 排序算法. // 生成一个指定数量的不含重复数字的随机数组 function ranArr(n,callback) { var res = []; var tmp ; ...

  6. 2050年这些职业将逐渐被AI(人工智能)取代

    耳熟能详的人工智能   深蓝Deep Blue是美国IBM公司生产的一台超级国际象棋电脑,重1270公斤,有32个大脑(微处理器),每秒钟可以计算2亿步."深蓝”输入了一百多年来优秀棋手的对 ...

  7. 【bzoj2038-小z的袜子】莫队算法

    莫队例题. 莫队学习:https://www.cnblogs.com/Paul-Guderian/p/6933799.html 本题 分子是sigma(c(sum[a[i]],2)),分母是sigma ...

  8. Codeforces Round #483 (Div. 2) [Thanks, Botan Investments and Victor Shaburov!]

    题目链接:http://codeforces.com/contest/984 A. Game time limit per test:2 seconds memory limit per test:5 ...

  9. 边缘检测:Canny算子,Sobel算子,Laplace算子

    1.canny算子 Canny边缘检测算子是John F.Canny于 1986 年开发出来的一个多级边缘检测算法.更为重要的是 Canny 创立了边缘检测计算理论(Computational the ...

  10. 大聊Python----SocketServer

    什么是SocketServer? SocketServer的最主要的作用是实现并发处理,也就是可以多个用户同时上传和下载文件. socketserver模块简化了编写网络服务器的任务. sockets ...