SQLite Forum

Nearest-match join
Login
As an aside, it's a bit unfortunate that I can't write

    select a, b, (select c, d from y where ......... limit 1) from t;
    Error: sub-select returns 2 columns - expected 1

Instead, I seem to have to get just one (unique) column in the sub-select and then join to get the others:

    select a, b, (select c from y where ...... limit 1), d from t join y on (c == y.c);

That's more verbose to write and also seems to have a more complex query plan.
Am I missing any tricks?