0
0

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 3 years have passed since last update.

実務でSQLをよく使用するので、
もう一度SQLの基礎を学習したのでまとめます。

・where句(なぜ?)
= 等しい

より大きい
= 以上
< より小さい
<= 以下
<> ! 等しくない
in ()、 ()にある値がセット内に含まれているか?
not in, ()にある値がセット内に含まれていないか?

(例)select (抽出したいカラム) from テーブル名 where (条件指定)

・group句 DBのカラムの同じ数値の値を抽出する。

select (抽出したいカラム) from テーブル名 group by (抽出したいカラム);

・having句
group句の後の集約結果をさらに絞り込む。(group by句の後に記入)
絞り込み条件はwhere句で使用した
= や > を記述する。

select (抽出したいカラム) from テーブル名 group by (抽出したいカラム) having (抽出条件);

・order by句 列(カラム)の並び替え
asc  昇順(小さい順)
desc 降順(大きい順)

select (抽出したいカラム) from テーブル名 order by (asc or desc);

・limit句 取得条件を制限できる。
select (テーブル名) users limit 10;

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?