Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8065351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:38:47+00:00 2026-06-05T11:38:47+00:00

I know that in oracle/mysql/sqlserver select statement you are not able to reference a

  • 0

I know that in oracle/mysql/sqlserver select statement you are not able to reference a column alias in the where clause because it is executed before the select, yet it works in sqlite3:

sqlite> create table t (c1 text, c2 text);
sqlite> insert into t values ("a1", "a2");
sqlite> insert into t values ("b1", "b2");
sqlite> select c1, c2 from t;
a1|a2
b1|b2
sqlite> select c1, c2 as alias_c2 from t where alias_c2='b2';
b1|b2

Why is this possible in sqlite?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:38:48+00:00Added an answer on June 5, 2026 at 11:38 am

    Using sqlite3 with SQLITE_DEBUG flag enabled:

    sqlite> create table x (x1 integer);
    sqlite> insert into x values (1);
    sqlite> insert into x values (2);
    sqlite> insert into x values (3);
    sqlite> insert into x values (4);
    sqlite> insert into x values (5);
    sqlite> pragma vdbe_listing=1;
    VDBE Program Listing:
       0 Expire           0    0    0      00 
       1 Halt             0    0    0      00 
    sqlite> select x1*x1 as s from x where s>-10 and s>-9 and s>0 and s>-4 and s>2;
    VDBE Program Listing:
       0 Trace            0    0    0      00 
       1 Integer        -10    1    0      00 
       2 Integer         -9    2    0      00 
       3 Integer          0    3    0      00 
       4 Integer         -4    4    0      00 
       5 Integer          2    5    0      00 
       6 Goto             0   26    0      00 
       7 OpenRead         0    3    0 1    00 x
       8 Rewind           0   24    0      00 
       9 Column           0    0    7      00 x.x1
      10 Multiply         7    7    6      00 
      11 Le               1   23    6      6A 
      12 Multiply         7    7    6      00 
      13 Le               2   23    6      6A 
      14 Multiply         7    7    6      00 
      15 Le               3   23    6      6A 
      16 Multiply         7    7    6      00 
      17 Le               4   23    6      6A 
      18 Multiply         7    7    6      00 
      19 Le               5   23    6      6A 
      20 Column           0    0    6      00 x.x1
      21 Multiply         6    6    9      00 
      22 ResultRow        9    1    0      00 
      23 Next             0    9    0      01 
      24 Close            0    0    0      00 
      25 Halt             0    0    0      00 
      26 Transaction      0    0    0      00 
      27 VerifyCookie     0    4    0      00 
      28 TableLock        0    3    0 x    00 
      29 Goto             0    7    0      00 
    s   
    ----
    4   
    9   
    16  
    25  
    sqlite> 
    

    As can be seen from the instruction stack above, the loop over the rows (lines 8-23) repeats the Multiply and Le commands for each expression in the where clause, for each row in the table.

    So to answer my own question, sqlite engine is able to use the column aliases by substituting their definitions from the select at execution time of the where.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Oracle, this returns 03/01/2010. That does not make sense to me. Anybody know
I know, that this type of indexes exist in Oracle. Old versions on MySQL
I know that in Oracle I can get the generated id (or any other
When writing a row-level trigger in Oracle, I know that you can use the
I know that != is not equal, but what does it mean when you
I know that Apple does not permit developers to read the phone number of
I'm looking for a tool that can watch database(mysql and oracle) for changes. When
we know that we can generate EDMX model from sql server because EF support
First, I know that the sql statement to update table_a using values from table_b
I know that some of the Microsoft employees are members of StackOverflow like the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.