175. Combine Two Tables【LeetCode】-LEFT JON 和RIGHT JOIN,两张表关联查询-java -sql入门
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 WHERE 的时候没有数据匹配就会返回空,但是你比如查询xx的住址可能是有人员信息么有地址
这个时候我们用LEFT JON 和RIGHT JOIN 什么意思呢,上语句查询结果你就懂了
#左连接就是左边查询的如果有数据右面如果没有匹配,那么右面的数据可以为空
#SELECT FirstName, LastName, City, State FROM Person left join Address on Person.PersonId=Address.PersonId;
#右连接就是右边查询的如果有数据左面如果没有匹配,那么右面的数据可以为空
SELECT FirstName, LastName, City, State FROM Address RIGHT join Person on Address.PersonId=Person.PersonId;
175. Combine Two Tables【LeetCode】-LEFT JON 和RIGHT JOIN,两张表关联查询-java -sql入门的更多相关文章
- 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 ...
- Leetcode 175. Combine Two Tables
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
- 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 ...
- 175. Combine Two Tables
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
- [LeetCode] Combine Two Tables 联合两表
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
随机推荐
- jenkins构建后操作添加“Publish to Subversion repository”与Eclipse更新提交SVN文件冲突
jenkins配置环境信息: 1.安装“SVN Publisher plugin”插件: 2.在系统管理-系统设置中“Global SVN Publisher Settings” 填写信息:
- 【LeetCode】233. Number of Digit One
题目: Given an integer n, count the total number of digit 1 appearing in all non-negative integers les ...
- ifame高度自动适应子页面内容
被这个问题折磨了好久,试了很多方法都不行,总算解决了,记录一下. <div class="iframe-pro" id="iframe-proid"> ...
- javascript之原型(prototype)
今天是第一次写博客,写点在javascript中重要的一个概念----原型(prototype): 原型,顾名思义,就是一切事物的模板. 柏拉图在<理想国>卷10中说:"床不是有 ...
- JanaScript数据类型
数据类型 一.基础类型值包括:undefined.null.boolean.string.number 基础类型分别在内存中占有大小空间,它们的值保存在栈空间,我们通过按值来访问. undefined ...
- HTML form表单小结
HTML form标签小结 最近研究 form标签,有一些小心得写下来与大家分享分享,共勉.在小结的最后有一个form表单的小例子,可以作为参考. -----DanlV form是HTML的一个极为重 ...
- geotrellis使用(二十九)迁移geotrellis至1.1.1版
目录 前言 升级过程 总结 一.前言 由于忙着安装OpenStack等等各种事情,有半年的时间没有再亲密的接触geotrellis,甚至有半年的时间没能畅快的写代码.近来OpenStac ...
- 【Python3之多线程】
一.threading模块 multiprocess模块的完全模仿了threading模块的接口,二者在使用层面,有很大的相似性. 1.开启线程的两种方式(同Process) 方法一 from thr ...
- getResources提取资源文件
String pxsize = context.getResources().getString(R.string.hello); 资源文件格式: <?xml version="1.0 ...
- jquery.jconfirm兼容IE6
因目标用户还在大量使用IE6(想吐CAO),只能做向下兼容,但之前使用的这个插件在IE6上并不支持.所以做了些处理才行. 以下为解决方法: IE6不支持position: fixed,所以需要对CSS ...