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

  • Home
  • SEARCH
  • 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 7814453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:11:55+00:00 2026-06-02T05:11:55+00:00

I have site http://change.is , i migrate it to new server. Now one of

  • 0

I have site http://change.is, i migrate it to new server. Now one of the sql query is showing odd result. The query is below:

SELECT distinct group_concat(pm.meta_value separator ' ') as composer, group_concat(pm.meta_value separator '-') as composer_link FROM $wpdb->postmeta pm where (pm.meta_key='composer_fname_value' OR pm.meta_key='composer_lname_value') and pm.post_id in (SELECT p.ID FROM $wpdb->posts p where p.post_type='quote' AND p.post_status='publish') group by pm.post_id order by group_concat(IF(pm.meta_key='composer_lname_value', pm.meta_value,'')) ASC

Explanation:

I have meta fields like author firstname, author lastname (what i needed in this query) in the admin section for custom post type “quote”. Before migrating to new server, this query is picking the author firstname & then author last name. So output become like ( Seteve Jobs, Jeff Bezos). After migrating, i added new post for this custom type ‘quote’. But now it is picking author last name & then author first name So output becomes like ( Diamandis Peter )

Point, it is picking this only for new post added, for old post in the database, it is coming fine.

Please help on this, or provide alternative query

  • 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-02T05:11:56+00:00Added an answer on June 2, 2026 at 5:11 am

    It looks like you want to order the pm.meta_values(s) in the group_concat depending on their associated pm.meta_key. When pm.meta_key=’composer_lname_value’, the value should come first.

    In this case, the easiest solution seems to use the optional ORDER BY clause of group_concat:

    SELECT distinct 
     group_concat(pm.meta_value order by IF(pm.meta_key='composer_lname_value', 1,0) separator ' ') as composer,
     group_concat(pm.meta_value order by IF(pm.meta_key='composer_lname_value', 1,0) separator '-') as composer_link
     ... the rest of the query being identical...
    

    Maybe that’s what you wanted to achieve with the ORDER BY at the end of the query, but this sorts output lines, not contents inside the same line.

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

Sidebar

Related Questions

I have site http://change.is where i used to use image blend like photoshop. On
I have site http://change.is/ on which i have to align footer grid to the
For example I have site http://localhost/site In IIS I set that 404 error causes
I have a simple web site ( http://www.kousenit.com/twitterfollowervalue ) that computes a quantity based
I have a site located at http://www.mySite.com . My html/PHP pages are located at
On this site: http://walkman.pk/aserdus2/tagok.php I have two background-images on the left and right side,
From this site: http://www.toymaker.info/Games/html/vertex_shaders.html We have the following code snippet: // transformations provided by
I have a url on my joomla site http://www.mysite.com/index.php?option=com_content&view=frontpage&Itemid=3220 My Customer wants it to
I have just installed CentOS, Apache and PHP. When I visit my site http://example.com/myapp/
We have a web site with domain http://209.59.154.150/~phnxaudi/ ,. To develop this website we

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.