コメントアウト方法
-- コメント
or
/* コメント*/
スキーマ
.schema
データベースの構造
データ型
・blob(Binary Large OBject)
→小さい画像やファイルなど保存できる
select関連
.headers on
カラム名を表示
select id, name as user_name from users;
id| user_name
select * from users
*すべて
where関連
複数の値のどれかに合致するものを抽出したい場合は in
select * from users where name in ('taguchi', 'fkoji');
taguchiとfkojiに当てはまるものすべて抽出
like関連
文字列に関して前方一致とか部分一致で抽出したい場合には like を用いる
select * from users where name like 's___';
文字列にsを含むものすべて
order by、limit関連
select * from users where score is not null order by score desc limit 3;
スコアの降順に並び替えて、3件表示に制限する。
viewで抽出条件を保存
hiscoreの定義
create view hiscore as select * from users order by score desc limit 5;
hiscoreの呼び出し
select * from hiscore;