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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:49:30+00:00 2026-05-23T22:49:30+00:00

I am working on wordpress and I need to generate timely csv files for

  • 0

I am working on wordpress and I need to generate timely csv files for the client, this has to include basic information about post from wp_posts like title, time & author. In Addition to this, I am using custom fields to store post_count, author name, author_email and few more meta fields.

Structure of wp_postmeta
id, meta_key, meta_value

Structure of wp_posts
id, title, date

wp_posts & wp_postmeta has 1:N relation.

If I do a simple innerjoin with statement

SELECT * FROM wp_posts INNER JOIN wp_postmeta where wp_postmeta.post_id = wp_posts.id

then I get a row for each meta value, but what I want is each meta value to become a column and only one row per post.

How to write this query?

Please assume this to be a standard wordpress database.

  • 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-23T22:49:32+00:00Added an answer on May 23, 2026 at 10:49 pm

    Use GROUP_CONCAT if you are running MySQL:

    SELECT wp_posts.*, GROUP_CONCAT(meta_value SEPARATOR ', ')
    FROM wp_posts INNER JOIN wp_postmeta USING post_id
    GROUP BY wp_posts.post_id;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a WordPress template and need to add a hyperlink to the
I'm working on a wordpress site, with a blog post that ends like: http://www.blog.com/?p=2
A wordpress theme I'm working on has headlines which span across the entire content
I'm working on a solution that has two applications 1) Wordpress based CRM (frontend)
I am working on a wordpress website where I need to get the number
I'm using the new wordpress custom post types and fields. It's all working great,
note: I'm working on wordpress but this isn't a wordpress question. I have a
I'm working on a Coldfusion project where I need to pull some information from
I just need some advice about using tags. I'm working on a website right
I am working on a wordpress site and I need some overlay windows. They

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.