(算術、比較、論理)演算子。
成果物
情報源
一覧
文字列結合
select 'A' || 'B';
AB
算術演算
select 'A' || 'B'; select 7 * 3; select 7 / 3; select 7 % 3; select 7 + 3; select 7 - 3;
21 2 1 10 4
ビット演算
2進数 | 10進数 |
---|---|
00 |
0 |
01 |
1 |
10 |
2 |
11 |
3 |
100 |
4 |
101 |
5 |
110 |
6 |
111 |
7 |
- 2進数
01
を1つ左シフトすると10
、2つ左シフトすると100
になる - 2進数
100
を1つ右シフトすると10
、2つ右シフトすると1
になる
select 0 << 1; select 1 << 1; select 2 << 1; select 3 << 1; select 0xF; select 0xF << 1;
0 2 4 6 15 30
select 0 >> 1; select 1 >> 1; select 2 >> 1; select 3 >> 1; select 0xF; select 0xF >> 1;
0 0 1 1 15 7
select 0 & 0; select 1 & 0; select 0 & 1; select 1 & 1; select 0 | 0; select 1 | 0; select 0 | 1; select 1 | 1;
0 0 0 1 0 1 1 1
比較演算子
select 5 < 6; select 5 < 5; select 6 < 5;
1 0 0
select 5 > 6; select 5 > 5; select 6 > 5;
0 0 1
select 5 <= 5; select 5 >= 5;
1 1
select 5 = 5; select 5 == 5; select 5 != 5; select 5 <> 5;
1 1 0 0
select 'A' = 'A'; select 'A' == 'A'; select 'A' != 'A'; select 'A' <> 'A';
1 1 0 0
select 5 is 5; select 5 is 6; select 5 is not 5; select 5 is not 6;
1 0 0 1
select 'A' is 'A'; select 'A' is 'B'; select 'A' is not 'A'; select 'A' is not 'B';
1 0 0 1
not
の位置が前後してわかりにくい。たとえばis
のときはnot
が後ろにくる。次のin
はnot
が前に来る。わかりにくい。覚えにくい。もう!
を先頭につけたら否定するで統一して。
select 5 in (1,3,5,7,9); select 5 not in (1,3,5,7,9);
1 0
論理演算子
``sql select 1 and 1; select 1 and 0; select 0 or 0; select 0 or 1;
1 0 0 1
select not 1; select not 0;
0 1
select (1 and 1) and (1 and 1); select (1 and 1) and (1 and 0); select not *1;
1 0 0
# 対象環境 * <time datetime="2019-09-03T13:21:08+0900" title="実施日">2019-09-03</time> * [Raspbierry pi](https://ja.wikipedia.org/wiki/Raspberry_Pi) 3 Model B+ * [Raspbian stretch](https://ja.wikipedia.org/wiki/Raspbian) 9.0 2018-11-13 * [bash](https://ja.wikipedia.org/wiki/Bash) 4.4.12(1)-release * [SQLite 3.29.0](http://ytyaru.hatenablog.com/entry/2021/06/28/000000) * [MeCab](http://ytyaru.hatenablog.com/entry/2021/02/21/000000) 0.996[ユーザ辞書](http://ytyaru.hatenablog.com/entry/2021/03/19/000000)
$ uname -a Linux raspberrypi 4.19.42-v7+ #1218 SMP Tue May 14 00:48:17 BST 2019 armv7l GNU/Linux
# 前回まで * [SQLite3学習 俯瞰まとめ](http://ytyaru.hatenablog.com/entry/2021/05/26/000000) * [SQLite3学習 環境構築まとめ](http://ytyaru.hatenablog.com/entry/2021/05/25/000000) * [SQLite3学習 インタフェースまとめ(C言語、CLI、対話モード、Tcl...)](http://ytyaru.hatenablog.com/entry/2021/05/24/000000) * [SQLite3学習 ドットコマンドまとめ](http://ytyaru.hatenablog.com/entry/2021/05/21/000000) * [SQLite3学習 JSON拡張まとめ](http://ytyaru.hatenablog.com/entry/2021/05/22/000000) * [SQLite3学習 FTSまとめ(ICU, MeCab)](http://ytyaru.hatenablog.com/entry/2021/05/23/000000) * [SQLite3学習 再帰クエリ(WITH RECURSIVE)](http://ytyaru.hatenablog.com/entry/2021/02/27/000000) * [SQLite3学習 R-Treeモジュール](http://ytyaru.hatenablog.com/entry/2021/02/28/000000) * [SQLite3学習 Geopoly(2次元ベクタ画像の生成)](http://ytyaru.hatenablog.com/entry/2021/05/28/000000) * [SQLite3学習 拡張関数(generate_series)](http://ytyaru.hatenablog.com/entry/2021/03/02/000000) * [SQLite3学習 拡張ライブラリ数学関数(extension-functions.c)](http://ytyaru.hatenablog.com/entry/2021/05/27/000000) * [SQLite3学習 謎と名前](http://ytyaru.hatenablog.com/entry/2021/05/29/000000) * [SQL文の分類(DDL,DML,TCL,DCL)](http://ytyaru.hatenablog.com/entry/2021/06/11/000000) * [SQL構文 alter(rename)](http://ytyaru.hatenablog.com/entry/2021/05/31/000000) * [SQL構文 alter(add column)概要](http://ytyaru.hatenablog.com/entry/2021/06/01/000000) * [SQL構文 alter(add column)制約](http://ytyaru.hatenablog.com/entry/2021/06/02/000000) * [SQL構文 alter(add column)sqlite_master変更しても反映されない](http://ytyaru.hatenablog.com/entry/2021/06/03/000000) * [SQL構文 alter(add column)スキーマ再定義(テーブル再作成による定義変更)](http://ytyaru.hatenablog.com/entry/2021/06/04/000000) * [SQL構文 analyze](http://ytyaru.hatenablog.com/entry/2021/06/07/000000) * [SQL構文 attach/detach](http://ytyaru.hatenablog.com/entry/2021/06/08/000000) * [SQLite3構文 begin,end,commit,rollback,savepoint(deferred,immediate,exclusive)](http://ytyaru.hatenablog.com/entry/2021/06/09/000000) * [SQLite3構文 コメント](http://ytyaru.hatenablog.com/entry/2021/06/10/000000) * [SQLite3構文 create/drop](http://ytyaru.hatenablog.com/entry/2021/06/12/000000) * [SQLite3構文 index(create/drop)](http://ytyaru.hatenablog.com/entry/2021/06/13/000000) * [SQLite3構文 table(create/drop)](http://ytyaru.hatenablog.com/entry/2021/06/14/000000) * [SQLite3構文 列制約(default)](http://ytyaru.hatenablog.com/entry/2021/06/15/000000) * [SQLite3構文 列制約(collate)](http://ytyaru.hatenablog.com/entry/2021/06/16/000000) * [SQLite3構文 列制約(primary key)](http://ytyaru.hatenablog.com/entry/2021/06/17/000000) * [SQLite3構文 列制約(primary key)ベストプラクティス](http://ytyaru.hatenablog.com/entry/2021/06/18/000000) * [SQLite3構文 列制約(unique)](http://ytyaru.hatenablog.com/entry/2021/06/19/000000) * [SQLite3構文 列制約(not null)](http://ytyaru.hatenablog.com/entry/2021/06/20/000000) * [SQLite3構文 列制約(check)](http://ytyaru.hatenablog.com/entry/2021/06/21/000000) * [SQLite3構文 列制約(foreign key references)](http://ytyaru.hatenablog.com/entry/2021/06/22/000000) * [SQLite3構文 表制約(primary key, unique, check, foreign key)](http://ytyaru.hatenablog.com/entry/2021/06/23/000000) * [SQLite3でメタデータを取得する方法(DB名(スキーマ名)、テーブル名、列名、制約)](http://ytyaru.hatenablog.com/entry/2021/06/24/000000) * [SQLite3でTEMPの保存先を指定する](http://ytyaru.hatenablog.com/entry/2021/06/25/000000) * [SQLite3構文 delete](http://ytyaru.hatenablog.com/entry/2021/06/26/000000) * [SQLite3ビルド失敗(SQLITE_ENABLE_UPDATE_DELETE_LIMIT)](http://ytyaru.hatenablog.com/entry/2021/06/27/000000) * [SQLite3をソースからビルドする(SQLITE_ENABLE_UPDATE_DELETE_LIMIT)](http://ytyaru.hatenablog.com/entry/2021/06/28/000000) * [SQLite3構文 delete(limit offset, order by)](http://ytyaru.hatenablog.com/entry/2021/06/29/000000) * [SQLite3クエリプランニング(インデックスの働き)](http://ytyaru.hatenablog.com/entry/2021/06/30/000000) * [SQLite3構文 explain](http://ytyaru.hatenablog.com/entry/2021/07/01/000000) * [SQLite構文 expression](http://ytyaru.hatenablog.com/entry/2021/07/02/000000) * [SQLite構文 expression(リテラル)](http://ytyaru.hatenablog.com/entry/2021/07/03/000000)
*1:1 and 1) and (1 and 1