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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:49:22+00:00 2026-05-15T20:49:22+00:00

I have two tables in MySQL, one containing a field City and one containing

  • 0

I have two tables in MySQL, one containing a field City and one containing a field HomeCounty. I need to get X number of records sorted alphabetically so that both City and HomeCounty are taken into the set.

I can’t join, because these two tables have no relation… and because I need these two columns to be “one”, not two.

So, I want all City records and HomeCounty records to be in one set, then sort that set alphabetically and limit it to X. I have really no idea what to do. Union?

  • 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-15T20:49:22+00:00Added an answer on May 15, 2026 at 8:49 pm

    Yes, you’d use a UNION:

    SELECT city AS name
      FROM TABLE_1
    UNION ALL
    SELECT homecountry AS name
      FROM TABLE_2
    ORDER BY name
       LIMIT ?
    

    Change to UNION if you have duplicates you want to remove, but it will be slower than UNION ALL.

    The ORDER BY in a UNION is applied to the entire resultset. If you wanted to apply different ORDER BY criteria to each statement in the UNION, you have to define the statement with brackets:

     (SELECT city AS name
        FROM TABLE_1
    ORDER BY name DESC)
    UNION ALL
    SELECT homecountry AS name
      FROM TABLE_2
       LIMIT ?
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two large tables in MySQL, one containing about 6,00,000 records and another
I have two MySQL database tables: one containing a list of championships and another
I have two mysql tables, one containing details on cars and one containing all
I have two mysql tables: Item containing items that one can buy: CREATE TABLE
In a MySQL database I have two tables linked in a join. One table
I'm new to MySQL and PHP. I have two tables, one to hold all
I have two tables in a MySql database: COUNTRY --------------- id, country_name and CITY
I have two mysql tables, one needs to start its auto-increment column id with
I have a simple mySQL problem-- I have two tables, one is a user's
I have two tables in MySql database, one is sales_order and the other is

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.