SQLite User Forum

Minor Documenation Nit ...
Login

Minor Documenation Nit ...

(1) By Keith Medcalf (kmedcalf) on 2022-12-18 03:25:17 [source]

In https://sqlite.org/lang_expr.html#subquery_expressions

A subquery that returns a single column is a scalar subquery and can be used most anywhere. A subquery that returns two or more columns is a row value subquery and can only be used as the operand of a comparison operator.

However,

sqlite> create table x(xa, xb);
sqlite> create table y(ya, yb);
sqlite> insert into x values ('xa', 'xb');
sqlite> insert into y values ('ya', 'yb');
sqlite> select * from x;
┌──────┬──────┐
│  xa  │  xb  │
├──────┼──────┤
│ 'xa' │ 'xb' │
└──────┴──────┘
sqlite> select * from y;
┌──────┬──────┐
│  ya  │  yb  │
├──────┼──────┤
│ 'ya' │ 'yb' │
└──────┴──────┘
sqlite> update x set (xa, xb) = (select ya, yb from y);
sqlite> select * from x;
┌──────┬──────┐
│  xa  │  xb  │
├──────┼──────┤
│ 'ya' │ 'yb' │
└──────┴──────┘
sqlite> select * from y;
┌──────┬──────┐
│  ya  │  yb  │
├──────┼──────┤
│ 'ya' │ 'yb' │
└──────┴──────┘
sqlite>

a row-value can also be used in a row-value assignment statement, not only in a comparison.

(2) By Larry Brasfield (larrybr) on 2022-12-18 03:48:50 in reply to 1 [link] [source]

Thanks for the pickup. Fixed here.

Not to be argumentative, but because the subject language was false and unduly restrictive, it was more than a mere nit.