I thought it was because what SQL returns is a value (in this case a string) and not an object?

The string value might be the same as the name of an object, but is not the object.

email signature Klaus Maas Klaus

On 2017-11-05 11:51, Richard Hipp wrote:
On 11/5/17, Shane Dev <devshan...@gmail.com> wrote:
In sqlite3, I executed the following statements -

sqlite> select name from tabs where rowid=1;
sqlite> select * from tab1;
first rec

sqlite> select * from (select name from tabs where rowid=1);

I expected the last statement to evaluate the subquery first to be 'tab1'
and then execute SELECT * FROM tab1 to yield 'first rec'. Why didn't this
Because that is not the way SQL works.  The statement

    SELECT * FROM (SELECT name FROM tabs WHERE rowid=1);

is logically equivalent to:

    CREATE TEMP TABLE "some-random-name" AS
              SELECT name FROM tabs WHERE rowid=1;
    SELECT * FROM "some-random-name";
    DROP TABLE "some-random-name";

SQL works on a compile-then-execute model.  Each SQL statement is
first analyzed and compiled into bytecode or into machine code or some
other executable format.  Then the resulting compiled code is run to
generate a result.  The names of tables and columns are fixed at
compile-time and cannot be modified at runtime, since to do so would
require on-the-fly changes to the compiled code.

sqlite-users mailing list

Reply via email to