175. Combine Two Tables (Easy)

Source: https://leetcode.com/problems/combine-two-tables/#/description

Description:

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

Solution:

select t0.FirstName,t0.LastName,t1.City,t1.State
from Person t0 left JOIN Address t1
ON t0.PersonId = t1.PersonId
时间: 2024-08-11 10:57:59

175. Combine Two Tables (Easy)的相关文章

LeetCode-Algorithms #001 Two Sum, Database #175 Combine Two Tables

最近两周一直感觉学习比较松懈, 打算加大一点强度, 从今天开始, 希望能在每天正常进度完成后在LeetCode上选一两题写一写, 同时学习一下高手的做法. LeetCode - Algorithms #001 Two Sum 给定一个整数数组, 找出其中两个元素, 使其和等于目标值, 返回这两个元素在原数组中的索引组成的数组. 可以假设有且只有一组正解, 且每个元素只能使用一次. 我的思路: 其实想不到什么好的方法, 遍历就好, 非常素朴的回答: 1 class Solution { 2 pub

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

https://leetcode.com/problems/combine-two-tables/ Combine Two Tables Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId | int | | FirstName | varchar | | LastName | varchar | +-------------+---------+

【SQL】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 +--

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 +--

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 +--

LeetCode:Combine Two Tables - 跨表查询

1.题目名称 Combine Two Tables(跨表查询) 2.题目地址 https://leetcode.com/problems/combine-two-tables/ 3.题目内容 现在有两张表Person和Address,它们的表结构如下: 表Person: +-------------+---------+ | Column Name | Type    | +-------------+---------+ | PersonId    | int     | | FirstNam

LeetCode - Combine Two Tables

Description: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: 第一次刷SQL题目感觉还是不错的.这个题目大概是说把第一张表和第二张表连接起来.而且第二张表中的Person的Address中的属性可能

LeetCode SQL: Combine Two Tables

SELECT FirstName, LastName, City, State FROM Person p LEFT JOIN Address a ON p.PersonId = a.PersonId 居然出SQL的题目了,左连接就行

【leetcode】Combine Two Tables

突然发现leetcode出sql题了,找了道最简单的,找找自信.. 题目如下: Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId | int | | FirstName | varchar | | LastName | varchar | +-------------+---------+ PersonId is the primary key c