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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:08:16+00:00 2026-06-05T07:08:16+00:00

I have a table in multi language cms, and I need an UNION SELECT

  • 0

I have a table in multi language cms, and I need an UNION SELECT to select tables from all languages, Is anyway that I define the current row is from witch table? something like this:

SELECT *,lan=en FROM en_table UNION SELECT *,lan=fa FROM fa_table ...

I know that I can use this:

SELECT *,(SELECT TABLE_NAME FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA = 'db' AND TABLE_NAME = 'en_table' LIMIT 1) As lan FROM en_table UNION ...

but this is stupid idea, is better way for doing this?

  • 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-05T07:08:18+00:00Added an answer on June 5, 2026 at 7:08 am

    Use a string literal enclosed in single quotes, with an alias as in:

    SELECT
      *,
      /* string literal 'en' */
      'en' AS lang
    FROM en_table
    UNOIN ALL
      *,
      /* string literal 'fa' */
      'fa' AS lang
    FROM fa_table
    

    Two things to note: It is unwise to use SELECT * in a UNION query. Be explicit about the columns instead, so their order is deterministic.

    SELECT
      col1,
      col2,
      'en' AS lang
    FROM en_table
    UNOIN ALL
      col1,
      col2,
      'fa' AS lang
    FROM fa_table
    

    Then, if at all possible, in the long term you should combine all these tables into one, which includes a column identifying the language. That will save you from having to complicate things with UNIONs later on.

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

Sidebar

Related Questions

I am building a multi language site I have a descriptions table that hold
I need to get the last inserted id of table that have multi-column primary
I have a large table with a multi-part index. I need to run several
I have a multi-row insert that looks something like: insert into table VALUES (1,
I have table A in Oracle that has a primary key (id). I need
I have a rails app that requires multi-table inheritance for which I am using
Have an options table that i'm trying to make multi lingual with an English
I have a table that has a column named 'languages', but it has the
MYSQL Database: I have a table of data that I need to put into
I'm dealing with a large multi-national corp. I have a table (oldtir) that shows

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.