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. 获取指定IP地址对应的物理位置

    # -*- coding: utf-8 -*- import requests def get_physical_location(ip): url = 'http://ip.taobao.com/s ...

  3. apache的作用和tomcat的区别

    经常在用apache和tomcat等这些服务器,可是总感觉还是不清楚他们之间有什么关系,在用tomcat的时候总出现apache,总感到迷惑,到底谁是主谁是次,因此特意在网上查询了一些这方面的资料,总 ...

  4. hdu 1166线段树 单点更新 区间求和

    敌兵布阵 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  5. Blender绘制大脑表层,并高亮染色

    首先, 有必要熟悉一下Blender的一些快捷键.(实在不想吐槽Blender反人类的交互操作了) 按鼠标右键是选择某个物体.(是右键,而不是左键!) 按A键,取消选中或者选中全部物体. 按H键,隐藏 ...

  6. POJ3026:Borg Maze (最小生成树)

    Borg Maze Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18644   Accepted: 5990 题目链接:h ...

  7. CopyOnWrite容器?

    CopyOnWrite容器即写时复制的容器.通俗的理解是当我们往一个容器添加元素的时候,不直接往当前容器添加,而是先将当前容器进行Copy,复制出一个新的容器,然后新的容器里添加元素,添加完元素之后, ...

  8. ios开关按钮

    .al-toggle-button{ appearance: none; -webkit-appearance: none; position: relative; width: 52px; heig ...

  9. Git版本管理1-安装配置和同步

    原文载于youdaonote,有图片: http://note.youdao.com/share/?id=79a2d4cae937a97785bda7b93cbfc489&type=note ...

  10. linux上抓包

    使用tcpdump命令. 使用tcpdump -help查看其用法. -i eth0:在第一块网卡上进行抓包. -w filename.cap:将抓的保存到当前目录下的filename.cap文件中, ...