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 665073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:40:11+00:00 2026-05-13T23:40:11+00:00

Suppose we got a original query as follows: SELECT A, B, C FROM tblA

  • 0

Suppose we got a original query as follows:

SELECT A, B, C FROM tblA

Now, I need to additional artificial rows like
SELECT ‘Kyala’, B, C FROM tblA when, for example, C = 100 to be inserted into the resultset.

As an example, if the tblA hold one row:

A      B      C
John   1      100

my goal is to return two rows like below with a single SQL query.

A      B      C
John   1      100
Kyala  1      100

How could I achieve it using a single SQL instead of relying on table variable or temp table?

  • 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-13T23:40:12+00:00Added an answer on May 13, 2026 at 11:40 pm

    You could achieve this with the UNION operator.

    SELECT A, B, C from tblA
    UNION
    SELECT 'Kyala', B, C FROM tblA WHERE C = 100
    

    In response to the question in the comments about improving performance so that the table is only queried once – you could add a covering index over columns C and B so that the second part of the query uses that index rather than querying the table:

    CREATE NONCLUSTERED INDEX [IX_tblA_CD] ON [dbo].[tblA] 
    (
        [C] ASC
    )
    INCLUDE ( [B]) ON [PRIMARY]
    GO
    

    However, depending on the use case (this sounds like some kind of ad-hoc process for testing?), you might prefer to take the hit of two table scans rather than adding a new index which might not be appropriate for use in production.

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

Sidebar

Related Questions

From http://items.sjbach.com/319/configuring-vim-right (2009 archive from original) I got that you were supposed to be
Suppose I've got the following program: namespace ReflectionTest { public class Example { private
Suppose I've got a table: Role ---- person_id company_id financial_year How can I tell
Suppose your git history looks like this: 1 2 3 4 5 1–5 are
This is the second time I have got confusing results from the modulo operator,
I've got an enum defined like this enum Tile { Empty, White, Black };
hello i got a problem with reading from a file, i am trying to
Suppose I got an apk file, how can I check the package of it?
I've got a table that is supposed to track days and costs for shipping
Suppose you have 2 different ASP.NET applications in IIS. Also, you have some ASCX

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.