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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:08:16+00:00 2026-06-02T16:08:16+00:00

I have 2 table posts and translation table post post_id post_content translation post_id language

  • 0

I have 2 table posts and translation

table post

  1. post_id
  2. post_content

translation

  1. post_id
  2. language
  3. content

This database will serve many language.
What is the best query to get a post with all available language in a row.

input
post_id = 2

output 
->single row with this fields

post_id = 2
post_content = 'lorem ipsum'
post_content_en = 'english lorem ipsum'
post_content_jp = 'japanese lorem ipsum'
post_content_...= 'bla..bla..bla..' //the post_content_xx is language international code

I have try using group_concat

SELECT a.post_id,GROUP_CONCAT(b.language,'--lang_content_separator--',b.content SEPARATOR '---main_separator---') AS all_languages
FROM posts a 
LEFT JOIN translation b ON a.post_id = b.post_id 
WHERE a.post_id = 2;

The above query is working, but I don’t like it, because we have to set group_concat_max_len.

Is there any trick, or alternate query to replace that group_concat?

  • 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-02T16:08:17+00:00Added an answer on June 2, 2026 at 4:08 pm

    I’m sure my solution can be improved, but an alternative is to do the merging of the arrays inside of PHP. In terms of the SQL query, you can run the query. The join in your query seems to be unnecessary.

    SELECT post_id, language, content FROM translation WHERE post_id = 2
    

    From PHP, you can then retrieve and format the data using the following code.

    $result = mysql_query($query);
    
    $post = array();
    while ($row = mysql_fetch_array($result)) {
        $index = "post_content_" . $row['language'];
        $post['post_id'] = $row['post_id'];
        $post[$index] = $row['content'];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a posts table structured this way: id | title | content |
I have two table posts & categories post_id | post_title | post_content | post_cat
I have a table posts with columns post_id , user_id , post . When
I have table posts and posts_votes . In posts_votes I have id and post_id
I have table called posts in my DB. Each post has field called social_network
I have a table posts that could look like this: id | title |
Ok, I have a database with with a table for storing classified posts, each
I have a table called posts with the following struture: post_id | post_body |
My question regards how to design a database. I have one table, called posts,
I have a table of posts and comments. Posts and comments have a post_id

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.