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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:10:03+00:00 2026-05-15T07:10:03+00:00

I have a table [Tbl1] containing two fields. ID as int And TextValue as

  • 0

I have a table [Tbl1] containing two fields.

ID as int And
TextValue as nvarchar(max)

Suppose there are 7 records. I need a resultset that has two columns Text1 and Text2.
The Text1 should have first 4 records and Text2 should have remaining 3 records.

[Tbl1]

ID | TextValue

1. | Apple

2. | Mango

3. | Orange

4. | Pineapple

5. | Banana

6. | Grapes

7. | Sapota

Now, the result-set should have


Text1 | Text2

Apple | Banana

Mango | Grapes

Orange | Sapota

Pineapple |

  • 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-15T07:10:04+00:00Added an answer on May 15, 2026 at 7:10 am

    I wonder how this can be useful, but I think you could try the following:

    SELECT      t1.TextValue AS Text1,
                t2.TextValue AS Text2
    FROM        tbl1 t1
    LEFT JOIN   tbl1 t2 ON ((t2.id - 4) = t1.id)
    WHERE       t1.id <= 4;
    

    Test case:

    CREATE TABLE tbl1 (id int, textvalue varchar(15));
    
    INSERT INTO tbl1 VALUES(1, 'Apple');
    INSERT INTO tbl1 VALUES(2, 'Mango');
    INSERT INTO tbl1 VALUES(3, 'Orange');
    INSERT INTO tbl1 VALUES(4, 'Pineapple');
    INSERT INTO tbl1 VALUES(5, 'Banana');
    INSERT INTO tbl1 VALUES(6, 'Grapes');
    INSERT INTO tbl1 VALUES(7, 'Sapota');
    

    Result:

    +-----------+--------+
    | Text1     | Text2  |
    +-----------+--------+
    | Apple     | Banana |
    | Mango     | Grapes |
    | Orange    | Sapota |
    | Pineapple | NULL   |
    +-----------+--------+
    

    UPDATE:

    As @AlexCuse suggested in a comment below, you could also use a variable to get the row count of the table, in order to have a query that works for any number of rows:

    DECLARE @x float;
    
    SET @x = ROUND((SELECT COUNT(*) FROM tbl1) / 2.0, 0);
    
    SELECT      t1.TextValue AS Text1,
                t2.TextValue AS Text2
    FROM        tbl1 t1
    LEFT JOIN   tbl1 t2 ON ((t2.id - @x) = t1.id)
    WHERE       t1.id <= @x;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say i have a table named tbl1 in mysql :- bookid int name varchar(20)
HiI have two tables. tbl1 id int(11) NOT NULL positionName varchar(20) NULL positionId int(11)
I have two tables. tbl1 id int(11) NOT NULL userName varchar(45) NOT NULL positionName
I have table with some fields that the value will be 1 0. This
I have table in data base name train delay, with columns train number(int), DelayTime(int),
I have the following table in my database: tbl1 PK ClientID ScheduleDay Time1Start Time1Stop
I have two same tables. I need to union them in such way: SELECT
I have basic tables one and two. Let`s call them tbl1 and tbl2. tbl1
I have (all InnoDB) a parent table tbl1 with primary key some_id and child
I have a table with following structure: TBL1 COL1 COL2 COL2 ---- ---- ----

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.