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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:09:35+00:00 2026-05-27T16:09:35+00:00

I have a terrible doubt. I have a query like this: SELECT id,fatherID FROM

  • 0

I have a terrible doubt.

I have a query like this:

SELECT id,fatherID FROM comments WHERE fatherID IS NULL 
 UNION
SELECT id,fatherID FROM comments WHERE fatherID IS NOT NULL 
 LIMIT 1

(Note the limit 1 applies to the union, not to only the second query)
(Note2: IS NULL, and IS NOT NULL are just an example, they can be a random string too)

With this limit 1 I am sure that this kind of query will return the row from the first query all the time?

Or even if both query returns something it can happen that the LIMIT 1 get the row coming from the second query?

I am asking this because If i run that query (wtihtou limit 1) I get this results

http://img856.imageshack.us/img856/5212/immaginejv.jpg

When I would except something like this (First all the rows with fatherid = null, then the other):

http://img847.imageshack.us/img847/479/immaginehx.jpg

  • 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-27T16:09:36+00:00Added an answer on May 27, 2026 at 4:09 pm

    Order of returned results is (by default) undefined. If you want them ordered in a specific manner, use ORDER BY, it was made to do exactly this.

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

Sidebar

Related Questions

I have Googled this a LOT but my C# skills are pretty terrible and
As terrible and disgusting as this sounds, I would like to be able to
im stuck in this terrible problem, I have a SOAP based webservice implemented in
Hi folks i have this terrible problems i hope any of you could help
I have a class that looks like this: class SearchService include Mongoid::Document key :name,
This is my first post and I have to admit, I am terrible at
I have a URL like this: http://www.domain.com/sponsor/xxxxx/reo/news It needs to end up being rewritten
After looking around (for not terribly long I have to admit) I wonder if
Have you managed to get Aptana Studio debugging to work? I tried following this,
I have a terrible piece of XML that I need to process through BizTalk,

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.