LoginSignup
9
7

More than 5 years have passed since last update.

テーブルの結合について色々(3つ結合、whereの場所、最新・最大のものを取得)

Posted at

・まず基本をこのサイトで押さえる
http://www.dbonline.jp/mysql/select/index15.html

・3つのテーブルを結合する場合
select * from テーブル1 left join テーブル2 using(list_id) left join テーブル3 using(list_id)

・whereの場所
select * from テーブル1 left join テーブル2 using(list_id) left join テーブル3 using(list_id) where 条件

・指定したカラムの値が最新や最大のものを取得する場合
select * from テーブル1 left join テーブル2 using(list_id) left join テーブル3 using(list_id) where 条件 order by カラム名 desc limit 1;
(順番に並べて一つだけ取得する)

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