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
 SELECT Person.FirstName,Person.LastName,Address.City,Address.State
FROM Person
Left JOIN Address
ON Person.PersonId=Address.PersonId

LeeCode(Database)-Combine Two Tables的更多相关文章

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

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

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

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

  3. LeeCode——Combine Two Tables

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

  4. [Leetcode|SQL] Combine Two Tables

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

  5. LeeCode(Database)-Customers Who Never Order

    Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...

  6. leetcode 175 Combine Two Tables join用法

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

  7. [LeetCode] Combine Two Tables 联合两表

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

  8. [leetcode]Combine Two Tables

    leetcode竟然有sql的题了..两道简单的应该会做 这个题主要就是一个left join... # Write your MySQL query statement below SELECT P ...

  9. LeeCode(Database)-Duplicate Emails

    Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...

随机推荐

  1. javascript遍历Json对象个数

       var data={};     for (var d in data) {         $(data[d]).each(function (i, e) {             aler ...

  2. 返回本机的外网ip地址

     ;             );             string ip = tempip.Replace("]", "").Replace(" ...

  3. MFC 消息的分类

    来源:孙鑫 c++ 第6集

  4. nodejs学习笔记之安装、入门

    由于项目需要,最近开始学习nodejs.在学习过程中,记录一些必要的操作和应该注意的点.       首先是如何安装nodejs环境?(我用的是windows 7环境,所以主要是windows 7的例 ...

  5. AngularJS 2调用.net core WebAPI的几个坑

    前几天,按照AngularJS2的英雄指南教程走了一遍,教程网址是http://origin.angular.live/docs/ts/latest/tutorial/. 在步骤完成后,又更进一步,在 ...

  6. (转)25个增强iOS应用程序性能的提示和技巧--中级篇

    在性能优化时,当你碰到一些复杂的问题,应该注意和使用如下技巧: 9.重用和延迟加载View10.缓存.缓存.缓存11.考虑绘制12.处理内存警告13.重用花销很大的对象14.使用Sprite Shee ...

  7. C++ - 容器(container)的erase()函数

    容器(container)的erase()函数 本文地址: http://blog.csdn.net/caroline_wendy/article/details/23996013 容器(contai ...

  8. (转)javascript中 window.location= window.location;是什么意思

    重载当前页面.但是,重载后,一些$_GET或者$_POST $_REQUEST 表单提交的数据会清空.   重新加载当前页面的资源,就是刷新本页面

  9. Android --------- 标签include位置设置无效

    给include设置below或align无效,是因为没有给include设置width和height.

  10. Autofac创建实例的方法总结 【转】

    Autofac创建实例的方法总结   1.InstancePerDependency 对每一个依赖或每一次调用创建一个新的唯一的实例.这也是默认的创建实例的方式. 官方文档解释:Configure t ...