Skip to Content
初めてのSQL 第3版
book

初めてのSQL 第3版

by Alan Beaulieu, 株式会社クイープ
July 2021
Intermediate to advanced
376 pages
6h 34m
Japanese
O'Reilly Japan, Inc.
Content preview from 初めてのSQL 第3版

5章複数のテーブルからデータを取得する

2章では、正規化と呼ばれるプロセスを通じて関連する概念をばらばらに分解する仕組みを確認しました。その最終的な結果として、personfavorite_foodの2つのテーブルが作成されました。しかし、住所氏名と好きな食べ物を1つのレポートにまとめたい場合は、これら2つのテーブルのデータを再び1つにまとめるメカニズムが必要です。このメカニズムを結合(join)と呼びます。本章では、最も単純で最もよく使われる内部結合(inner join)に焦点を合わせます。10 章では、さまざまな種類の結合を具体的に見ていきます。

5.1 結合とは何か

1つのテーブルに対するクエリは特に珍しくありませんが、ほとんどのクエリでは、2つ、3つ、あるいはそれ以上のテーブルが必要になります。具体的な例として、customerテーブルとaddressテーブルの定義を調べた後、両方のテーブルからデータを取得するクエリを定義してみましょう。

mysql> desc customer; +-------------+-------------------+------+-----+-------------------+ | Field | Type | Null | Key | Default | +-------------+-------------------+------+-----+-------------------+ | customer_id | smallint unsigned | NO | PRI | NULL | | store_id | tinyint unsigned | NO | MUL | NULL | | first_name | ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Googleのソフトウェアエンジニアリング ―持続可能なプログラミングを支える技術、文化、プロセス

Googleのソフトウェアエンジニアリング ―持続可能なプログラミングを支える技術、文化、プロセス

Titus Winters, Tom Manshreck, Hyrum Wright, 竹辺 靖昭, 久富木 隆一

Publisher Resources

ISBN: 9784873119588Other