17
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【PostgreSQL】内部結合の方法

Last updated at Posted at 2017-10-27

内部結合(2つのテーブルを結合)

table1とtable2をidで結合し、table2のheightが 100 より大きいものだけをtable1からselectする

sql
select *
    from table1
    inner join table2 on table1.id = table2.id
where
    table2.height > 100;

内部結合(3つのテーブルを結合)

table1とtable2とtable3をidで結合しtable2のheightが50より大きく且つtable3のheightが100より大きいものだけをtable1からselectする

sql

select *
   from table1
   inner join table2 on table1.id = table2.id
   inner join table3 on table1.id = table3.id
where
   table2.height > 50
   and
   table3.height > 100

17
6
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
17
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?