SQLite VDBE opcode

And

Take the logical AND of the values in registers P1 and P2 and write the result into register P3.

An example

1 of the 178 statements we compiled against the sample database use And. This is the one with the shortest program; the rows that use And are highlighted.

SELECT (id > 5) AND (ms > 1000), (id > 5) OR (ms > 1000) FROM tracks
addropcodep1p2p3p4p5
0Init02400
1OpenRead04040
2Rewind02300
3Rowid0300
4Integer1100
5Gt47368
6ZeroOrNull3140
7Column0350
8Integer1300
9Gt6115BINARY-868
10ZeroOrNull5360
11And3110
12Rowid0300
13Integer1200
14Gt416368
15ZeroOrNull3240
16Column0350
17Integer1300
18Gt6205BINARY-868
19ZeroOrNull5360
20Or3220
21ResultRow1200
22Next0301
23Halt0000
24Transaction00101
25Integer5400
26Integer1000600
27Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Column, Goto, Gt, Halt, Init, Integer, Next, OpenRead, Or, ResultRow, Rewind, Rowid, Transaction, ZeroOrNull.

What the SQLite documentation says

Take the logical AND of the values in registers P1 and P2 and write the result into register P3.

If either P1 or P2 is 0 (false) then the result is 0 even if the other input is NULL. A NULL and true or two NULLs give a NULL output.

From sqlite.org's list of opcodes for SQLite 3.54.1, in the public domain. Opcodes are not a stable interface and change between releases.

← AggValue · AutoCommit →