Skip to Content
SQL の使用を開始
book

SQL の使用を開始

by Thomas Nield
May 2025
Intermediate to advanced
134 pages
1h 43m
Japanese
O'Reilly Media, Inc.
Content preview from SQL の使用を開始

付録A. 演算子と関数

この付録はSQLiteでよく使われる演算子や関数を便利なリファレンスとして取り上げている。本書はSQLiteのすべての関数を網羅しているわけではないが、すぐに必要になるであろう関数はここで発見することができる。第一の目的は、ほとんどのプラットフォームに適用できる普遍的なSQLの概念を紹介することであり、SQLiteプラットフォームのニュアンスを詳しく教えることではない。

SQLiteの機能の包括的なカバレッジは、https://www.sqlite.org/docs.html で発見できる。

付録A1 - 文字式クエリ

、テーブルをクエリすることなく、簡単に演算子や関数をテストすることができる。次のクエリのように、リテラルの式をSELECT

SELECT 5 + 7

文字列を含むあらゆる関数やリテラルも、この方法でテストすることができる。このクエリは、'TONY' という単語が'TONY STARK' という文字列の中にあるかどうかをチェックし、1 を返す:

SELECT INSTR('TONY STARK', 'TONY')

これは、テーブルを使わずに演算子や関数をテストする素晴らしい方法である。この付録では、この方法を使った多くの例を紹介する。

付録A2 - 数学演算子

SQLiteには、基本的な演算子がいくつか用意されている。 より高度な処理は通常関数を使うが、ここでは5つのコア演算子を紹介する。

x = 7、y = 3とする

演算子 説明 結果
+ 2つの数値を足す x + y 10
- 2つの数字を減算する x - y 4
* 2つの数値を掛け合わせる x * y 21
/ 2つの数を割る x / y 2
% 2つの数値を除算し、余りを返す。 x % y 1

付録A3 - 比較演算子

比較演算子は、比較評価に基づいて、真(1)または偽(0)の値をもたらす。

x=5、y=10とする

演算子 説明 結果
= そして== 2つの値が等しいかどうかをチェックする x = y 0 (偽)
!= そして<> 2つの値が等しくないかチェックする x != y 1(真)
> 左の値が右の値より大きいかどうかをチェックする x > y 0 (偽)
< 左の値が右の値より小さいかどうかをチェックする x < y 1(真)
>= 左の値が右の値以上かどうかをチェックする x >= y 0 (偽)
<= 左の値が右の値以下かどうかをチェックする x <= y 1(真)

付録A4 - 論理演算子

論理演算子 を使うと、 ブール式を組み合わせることができるだけでなく、より多くの条件付き演算を行うことができる。

x=真(1)、y=偽(0)と仮定する。

a = 4、b = 10とする

演算子 説明 結果
AND すべてのブール式が真であるかどうかをチェックする。 x AND y 0 (偽)
OR 任意のブール式が真であるかどうかをチェックする。 x OR y 1(真)
BETWEEN 値が範囲に含まれるかどうかをチェックする。 a BETWEEN 1 and b 1(真)
IN 値が値のリストにあるかどうかをチェックする a IN (1,5,6,7) 0 (偽)
NOT ブール式の値を否定し、反転させる。 a NOT IN (1,5,6,7) 1(真)
IS NULL 値がNULLかどうかをチェックする ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

MySQL クックブック、第 4 版

MySQL クックブック、第 4 版

Sveta Smirnova, Alkin Tezuysal
コンピュータビジョンのための実践機械学習 ―モデルアーキテクチャからMLOpsまで

コンピュータビジョンのための実践機械学習 ―モデルアーキテクチャからMLOpsまで

Valliappa Lakshmanan, Martin Görner, Ryan Gillard, 大山 匠, 松田 晃一

Publisher Resources

ISBN: 9798341651029