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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:32:38+00:00 2026-06-13T20:32:38+00:00

the table id string ———— 1 aaa 2 bbb 3 ccc 4 ddd the

  • 0

the table

id    string
------------
1     aaa
2     bbb
3     ccc
4     ddd

the query

(SELECT string FROM table WHERE id > 1 ORDER BY id ASC LIMIT 1)    /* num_row = 1 */
UNION
(SELECT string FROM table WHERE id < 1 ORDER BY id DESC LIMIT 1)   /* null */
UNION
(SELECT string FROM table WHERE id > 4 ORDER BY id ASC LIMIT 1)    /* null */
UNION
(SELECT string FROM table WHERE id < 4 ORDER BY id DESC LIMIT 1)   /* num_row = 2 */

The query above will return 2 rows since there are no id=5 and id=0.

How can I tell which queries are these 2 rows fetched from?

that is, num_row = 1 from 1st SELECT, and num_row = 2 from 4th SELECT

  • 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-13T20:32:39+00:00Added an answer on June 13, 2026 at 8:32 pm

    use a second column to indicate from where the data comes from

    (SELECT string, '1st query' as from_where FROM table WHERE ...)
    UNION
    (SELECT string, '2nd query' as from_whereFROM table WHERE ...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why is using a parameterized query to insert data into a table: string queryString
i have a table array dynamically generated from a data query and stored in
Imagine a table like: string 12345 1234567 13254 123 I just want to select
this is my code to create database table String sqlQueryToCreateFileTable = create table if
I have a table with string values that need to matched individually to a
I want to create a table with String keyvalues and integer data. Right now
I have a table with 5 string columns, all can be NULLs. After I
I have a table as Name(String) fromRange(int) toRange(int) abc 15160 15180 bhy 12510 12515
Lets assume I get an HTML table as a string, and I want -
I'm trying to store today's date in a sqlite table as a string in

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.