博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【leetcode】Combine Two Tables (MySQL)
阅读量:7208 次
发布时间:2019-06-29

本文共 1007 字,大约阅读时间需要 3 分钟。

hot3.png

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

就是简单的写SQL语句。。。

解题思路:

这个就简单的用一个左连接就可以了,(虽然看分析数据时发现速度没别人的快

# Write your MySQL query statement belowselect FirstName, LastName, City, Statefrom Person left join Address on Person.PersonId = Address.PersonId

主要去理解各种连接吧。

这里有一个很好的博文哦:

转载于:https://my.oschina.net/ruanhang1993/blog/535691

你可能感兴趣的文章
不好意思,观察者模式跟发布订阅模式就是不一样
查看>>
蒙了吗?offsetLeft、offsetWidth、scrollTop、scrollWidth、event.pageX
查看>>
直播的学习与使用-----采集
查看>>
老项目引入masonry后报错unrecognized selector sent to instance
查看>>
如果往错误的NEO地址转账会发生什么
查看>>
2018 年终总结
查看>>
如何使用Gitbook创建html技术文档
查看>>
GDB 调试 Mysql 实战(一)源码编译安装
查看>>
理解AJAX
查看>>
通信类
查看>>
Android4.4 及以下TextView,Button等控件使用矢量图报错
查看>>
浏览器回流认识
查看>>
react生命周期
查看>>
质因子分解
查看>>
Django搭建个人博客:文章标签功能
查看>>
Docker学习笔记
查看>>
61. Rotate List
查看>>
Linux CTF 逆向入门
查看>>
LeetCode-数组-三数之和
查看>>
Alain 菜单权限控制
查看>>