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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:54:19+00:00 2026-06-15T23:54:19+00:00

I have two table with this structure categories ——————————– id | create 1 |

  • 0

I have two table with this structure

categories
--------------------------------
id  | create
1   | 2012-12-01 12:00:00
2   | 2012-12-01 12:00:00

category_i18ns
--------------------------------
category_id     | lang  | title
1               | en    | home page
1               | de    | HomE PAGEa
1               | fa    | خانه
2               | en    | about

some categories have all languages data and some another havnt. for example category id 2 just have en translated title. i want to have a query that first check the current language for retrieve title and then if not exist then show another ones.

i have a query to get current category data with i18n data
in this current example de is default language. for category id 1 we have de title but for category 2 we dont. so i want english version as title of category

SELECT * FROM `mhf_swe_ndzhmju3_test`.`categories` AS `Category`
LEFT JOIN `mhf_swe_ndzhmju3_test`.`category_i18ns` AS `CategoryLocale` ON (
`CategoryLocale`.`category_id` = `Category`.`id`
AND `CategoryLocale`.`lang` = 'de')

desire out put for ‘de’ language

Category.id     CategoryLocale.title    CategoryLocale.lang
1               HomE PAGEa              de
2               about                   en
  • 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-15T23:54:20+00:00Added an answer on June 15, 2026 at 11:54 pm
    SELECT Category.id,
            COALESCE(a.lang, b.lang) lang,
            COALESCE(a.title, b.title) title
    FROM   categories AS Category
          LEFT JOIN category_i18ns AS a
               ON a.category_id = Category.id AND a.lang = 'de'
          LEFT JOIN category_i18ns AS b
               ON b.category_id = Category.id AND b.lang = 'en'
    
    • 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 tables, A and B. The structure looks like this: CREATE TABLE
I have two table like this table_CN (_id, name, phone, favorite, title) table_EN (_id,
I am using luasql. I have two tables of this type: IPINFO CREATE TABLE
I have table with this structure ID PK and two columns with FK for
I have two table The table structure goes something like this Table A ╔══════╦════════╗
I have two tables with this structure: Table one: ID Description Table two: ID
I have two tables like of this structure: content (content_id, content_type, user_id, time, comment_count)
I have two tables which looks something like this Table Queue int ID; string
I have this two tables: Table A ID TYPE SDATE EDATE RATING 1 M
I have table with two columns (varchar from, varchar to). This table represents connections

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.