Leetcode 175. 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
本题的思路很简单,由于FirstName, LastName, City, State 来自两个不同的 table, 所以要用join。由于要求必须显示人名,即使没有地址相关信息,说明要用LEFT JOIN。经测试LEFT JOIN和LEFT OUTER JOIN效果一样。
# Write your MySQL query statement below
SELECT FirstName, LastName, City, State FROM Person
LEFT JOIN Address ON Person.PersonId = Address.PersonId
Leetcode 175. Combine Two Tables的更多相关文章
- LeetCode 175. Combine Two Tables 【MySQL中连接查询on和where的区别】
一.题目 175. Combine Two Tables 二.分析 连接查询的时候要考虑where和on的区别 where : 查询时,连接的时候是必须严格满足条件的,满足了才会加入到临时表中. on ...
- 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 join用法
https://leetcode.com/problemset/database/ ACM退役,刚好要学sql,一定要刷题才行,leetcode吧. 这一题,说了两个表,一个左一个右吧,左边的pers ...
- LeetCode 175. Combine Two Tables (组合两个表)
题目标签: 题目给了我们两个table,让我们合并,根据Person为主. 因为题目说了 提供person 信息,不管这个人有没有地址.所以这里用Left Join. Java Solution: R ...
- 175. Combine Two Tables【LeetCode】-LEFT JON 和RIGHT JOIN,两张表关联查询-java -sql入门
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
- [Leetcode|SQL] Combine Two Tables
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
- sql 中多表查询-leetcode : Combine Two Tables
因为对数据库的内容早都忘得差不多了,所以我的第一感觉是: select Person.FirstName, Person.LastName, Address.City from Person, Add ...
- leetcdoe 175. Combine Two Tables
给定两个表,一个是人,一个是地址,要求查询所有人,可以没有地址. select a.FirstName, a.LastName, b.City, b.State from Person as a le ...
- 【SQL】175. Combine Two Tables
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
随机推荐
- cakephp , the subquery
Cakephp 框架帮我们做了很多的工作,的确省了我们很多工作,提高了效率. 但是,碰到一些比较复杂的查询时,还是有些问题,官方的cookbook api 有说明一些详细的用法,但感觉还是不太够,有些 ...
- FusionCharts使用问题及解决方法(二)-FusionCharts常见问题大全
在上文中,我们介绍了FusionCharts常见问题(FAQ)的解决方法,本文将一同讨论FusionCharts使用者面临的一些复杂问题的解决方法. 如何启用JavaScript调试模式? 要启用Ja ...
- CentOS 6.3下NTP服务安装和配置
测试环境: NTPserver 192.168.1.252 NTPclient 192.168.1.251 准备工作: 关闭selinux: vi /etc/selinux/config SELINU ...
- sockaddr结构体
sockaddr 本词条缺少名片图,补充相关内容使词条更完整,还能快速升级,赶紧来编辑吧! 一,用于存储参与(IP)Windows套接字通信的计算机上的一个internet协议(IP)地址.为了统一地 ...
- conflicting types for xxxx错误 (转)
pretty_print.c:31: error: conflicting types for ‘vmi_print_hex’ libvmi.h:749: note: previous declara ...
- USACO Section 1.2 Name That Number 解题报告
题目 题目描述 在一个农场里面,每一头牛都有一个数字编号,但是现在这些牛不喜欢这种编号,它们想把这些数字编号转化成为可以接受的字母的形式.数字与字母的转换表如下: 2: A,B,C 5: J,K,L ...
- Windows Server 2012 在个人终端上使用的推荐设置
Windows Server 2012,也就是 Windows 8 的服务器版本,相对于 Windows 8 企业版而言,增强了作为服务器的功能,弱化了作为终端系统的功能. 目前微软官方提供了 Win ...
- Android音频系统之AudioFlinger(一)
1.1 AudioFlinger 在上面的框架图中,我们可以看到AudioFlinger(下面简称AF)是整个音频系统的核心与难点.作为Android系统中的音频中枢,它同时也是一个系统服务,启到承上 ...
- MC34063+MOSFET扩流 12V-5V 折腾出了高效率电路(转)
源:http://www.amobbs.com/thread-5484710-1-1.html 从网上找到一些MC34063扩流降压电路图,一个个的试,根本达不到我的基本要求,全都延续了34063的降 ...
- 卷积神经网络在tenserflow的实现
卷积神经网络的理论基础看这篇:http://blog.csdn.net/stdcoutzyx/article/details/41596663/ 卷积神经网络的tenserflow教程看这里:http ...