LoginSignup
0
0

More than 3 years have passed since last update.

テーブルの結合

Posted at

テーブルの結合には、 INNER JOIN テーブル名 ON 条件 キーワードを使用

mysql> SELECT * FROM books INNER JOIN chapters ON books.id = chapters.book_id;

SELECT * FROM books
SELECT * FROM books は単純に books テーブルの一覧を表示

INNER JOIN chapters
INNER JOIN chapters が接続されることで、テーブルが結合

ON books.id = chapters.book_id
そこで、 ON books.id = chapters.book_id を加えて、この条件に沿わない結合パターンは消す

テーブルの結合は一対多、多対多で活躍する

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0