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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:51:21+00:00 2026-06-09T11:51:21+00:00

I have the following database structure table_1 text_1 (INT) text_2 (INT) i18n id_i18n (PK

  • 0

I have the following database structure

table_1
  text_1 (INT)
  text_2 (INT)


i18n
  id_i18n (PK INT)
  locale  (PK VARCHAR(5))
  text    (TEXT)

On table_1, the columns text_1 and text_2 are foreign keys pointing to some i18n.id_i18n entries.
I can easily join the entries for a specific locale

SELECT t1.text as text_1, t2.text as text_2
FROM table_1
LEFT JOIN i18n as t1 ON text_1 = t1.id_i18n and t1.locale = "en_us"
LEFT JOIN i18n as t2 ON text_2 = t2.id_i18n and t2.locale = "en_us"

I can also get the following

row1: locale, text_1, text_2
row2: locale, text_1, text_2
row3: locale, text_1, null
row4: locale, text_1, text_2

using this query

SELECT t1.text as text_1, t2.text as text_2
FROM room
LEFT JOIN i18n as t1 ON text_1 = t1.id_i18n
LEFT JOIN i18n as t2 ON text_2 = t2.id_i18n and t1.locale = t2.locale
group by t1.locale;

assuming the I have the following i18n entries

      id_i18n   locale  text
row1: 1         en_us   text_1_for[en_us]
row2: 1         en_gb   text_1_for[en_gb]
row3: 1         el_gr   text_1_for[el_gr]
row4: 2         en_us   text_2_for[en_us]
row5: 2         en_gb   text_2_for[en_gb]
row6: 2         pr_pk   text_2_for[pr_pk]
row7: 1         en_ca   text_1_for[en_ca]

and then a table that links to those named tbl

     id, i18n_text_1, i18n_text_2
row1 1   1            2

I want to produce a result set like

      locale,  text_1,              text_2
row1: en_us    text_1_for[en_us]    text_2_for[en_us]
row2: en_gb    text_1_for[en_gb]    text_2_for[en_gb]
row3: el_gr    text_1_for[el_gr]    null
row4: pr_pk    null                 text_2_for[pr_pk]
row5: en_ca    text_1_for[en_ca]    null

Hope this helps 🙂

  • 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-09T11:51:22+00:00Added an answer on June 9, 2026 at 11:51 am

    Try this:

    SELECT     a.locale, c.text AS text_1, d.text AS text_2
    FROM       (SELECT DISTINCT locale FROM i18n) a
    CROSS JOIN table_1 b
    LEFT JOIN  i18n c ON b.text_1 = c.id_i18n AND a.locale = c.locale
    LEFT JOIN  i18n d ON b.text_2 = d.id_i18n AND a.locale = d.locale
    

    SQLFiddle Demo


    EDIT: This might work better:

    SELECT
        a.locale, b.text_1, c.text_2
    FROM
        (SELECT DISTINCT locale FROM i18n) a
    LEFT JOIN
    (
        SELECT b.locale, b.text AS text_1
        FROM   table_1 a
        JOIN   i18n b ON a.text_1 = b.id_i18n
    ) b ON a.locale = b.locale
    LEFT JOIN
    (
        SELECT b.locale, b.text AS text_2
        FROM   table_1 a
        JOIN   i18n b ON a.text_2 = b.id_i18n
    ) c ON a.locale = c.locale
    

    SQLFiddle Demo

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

Sidebar

Related Questions

I have two database tables with the following structure: actions: action_id int(11) primary key
I have no control over database schema and have the following (simplified) table structure:
I have the following database structure. ID | Name | Marks I am trying
I have the following table structure: CREATE TABLE [Report].[MesReport]( [MesReportID] [int] IDENTITY(1,1) NOT NULL,
I have a database/table in SQLITE using the following structure CREATE TABLE milestones (
I have the following database structure: Sites table id | name | other_fields Backups
I have the following database structure: Children --> Gifts <-- Possible_gifts, where the arrow
I have the following database structure: Table 1 Table 2 Table 3 tid_1 ----(many-to-one)----
The following is the structure of database table consisiting of foreign keys from two
I have the following database table object: public class Goal { @DatabaseField(generatedId = true)

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.