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

  • SEARCH
  • Home
  • 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 6556101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:54:04+00:00 2026-05-25T12:54:04+00:00

How does SQLite internally treats the alias? Does creating a table name alias internally

  • 0

How does SQLite internally treats the alias?

Does creating a table name alias internally creates a copy of the same table or does it just refers to the same table without creating a copy?

When I create multiple aliases of the same table in my code, performance of the query is severely hit!

In my case, I have one table, call it MainTable with namely 2 columns, name and value.
I want to select multiple values in one row as different columns. for example

Name: a,b,c,d,e,f
Value: p,q,r,s,t,u
such that a corresponds to p and so on.

I want to select values for names a,b,c and d in one row => p,q,r,s
So I write a query

SELECT t1.name, t2.name, t3.name, t4.name  
FROM MainTable t1, MainTable t2, MainTable t3, MainTable t4
WHERE t1.name = 'a' and t2.name = 'b' and t3.name = 'c' and t4.name = 'd';

This way f writing the query kills the performance when size of the table increases as rightly pointed above by Larry.

Is there any efficient way to retrieve this result. I am bad at SQL queries 🙁

  • 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-05-25T12:54:05+00:00Added an answer on May 25, 2026 at 12:54 pm

    Assuming you have table dbo.Customers with a million rows

    SELECT * from dbo.Customers A
    

    does not result in a copy of the table being created.

    As Larry pointed out, the query as it stands is doing a cartesian product across your table four times which, as you has observed, kills your performance.

    The updated ticket states the desire is to have 4 values from different queries in a single row. That’s fairly simple, assuming this syntax is valid for sqllite

    You can see that the following four queries when run in serial produce the desired value but in 4 rows.

    SELECT t1.name
    FROM MainTable t1
    WHERE t1.name='a';
    
    SELECT t2.name
    FROM MainTable t2
    WHERE t2.name='b';
    
    SELECT t3.name
    FROM MainTable t3
    WHERE t3.name='c';
    
    SELECT t4.name
    FROM MainTable t4
    WHERE t4.name='d';
    

    The trick is to simply run them as sub queries like so there are 5 queries: 1 driver query, 4 sub’s doing all the work. This pattern will only work if there is one row returned.

    SELECT
    (
        SELECT t1.name
        FROM MainTable t1
        WHERE t1.name='a'
    ) AS t1_name
    ,
    (
        SELECT t2.name
        FROM MainTable t2
        WHERE t2.name='b'
    ) AS t2_name
    ,
    (
        SELECT t3.name
        FROM MainTable t3
        WHERE t3.name='c'
    ) AS t3_name
    , 
    (
        SELECT t4.name
        FROM MainTable t4
        WHERE t4.name='d'
    ) AS t4_name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just getting into SQLite and I understand it does not use datatypes the same
Does SQLite support seeding the RANDOM() function the same way MySQL does with RAND()
Does anybody know if there is a way to create an SQLite database based
I am creating my SQLite database for my App at runtime if it does
I really like Xml for saving data, but when does sqlite/database become the better
Why does the SQLite C/C++ API return unsigned char * s for text values
Does the iPhone's SQLite implementation support the full SQLite 3 standard? That is, is
Does someone know of a Sqlite manager that I can put on my site,
Does anyone have any examples of using Sqlite with ASP.NET membership? I am building
does it make sense to use an Filecache when using Sqlite as Database ?

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.