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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:17:55+00:00 2026-06-11T19:17:55+00:00

I will try to explain things as much as I can. I have following

  • 0

I will try to explain things as much as I can.
I have following query to fetch records from different tables.

SELECT 
  p.p_name,
  p.id,
  cat.cat_name,
  p.property_type,
  p.p_type,
  p.address,
  c.client_name,
  p.price,
  GROUP_CONCAT(pr.price) AS c_price,
  pd.land_area,
  pd.land_area_rp,
  p.tagline,
  p.map_location,
  r.id,
  p.status,
  co.country_name,
  p.`show`,
  u.name,
  p.created_date,
  p.updated_dt,
  o.type_id,
  p.furnished,
  p.expiry_date 
FROM
  property p 
  LEFT OUTER JOIN region AS r 
    ON p.district_id = r.id 
  LEFT OUTER JOIN country AS co 
    ON p.country_id = co.country_id 
  LEFT OUTER JOIN property_category AS cat 
    ON p.cat_id = cat.id 
  LEFT OUTER JOIN property_area_details AS pd 
    ON p.id = pd.property_id 
  LEFT OUTER JOIN sc_clients AS c 
    ON p.client_id = c.client_id 
  LEFT OUTER JOIN admin AS u 
    ON p.adminid = u.id 
  LEFT OUTER JOIN sc_property_orientation_type AS o 
    ON p.orientation_type = o.type_id 
  LEFT OUTER JOIN property_amenities_details AS pad 
    ON p.id = pad.property_id 
  LEFT OUTER JOIN sc_commercial_property_price AS pr 
    ON p.id = pr.property_id 
WHERE p.id > 0 
  AND (
    p.created_date > DATE_SUB(NOW(), INTERVAL 1 YEAR) 
    OR p.updated_dt > DATE_SUB(NOW(), INTERVAL 1 YEAR)
  ) 
  AND p.p_type = 'sale' 

everything works fine if I exclude GROUP_CONCAT(pr.price) AS c_price, from above query. But when I include this it just gives one result. My intention to use group concat above is to fetch comma separated price from table sc_commercial_property_price that matches the property id in this case p.id. If the records for property exist in sc_commercial_property_price then fetch them in comma separated form along with other records. If not it should return blank. What m I doing wrong here?

I will try to explain again if my problem is not clear. Thanks in advance

  • 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-11T19:17:56+00:00Added an answer on June 11, 2026 at 7:17 pm

    The GROUP_CONCAT is an aggregation function. When you include it, you are telling SQL that there is an aggregation. Without a GROUP BY, only one row is returns, as in:

    select count(*)
    from table
    

    The query that you have is acceptable syntax in MySQL but not in any other database. The query does not automatically group by the columns with no functions. Instead, it returns an arbitrary value. You could imagine a function ANY, so you query is:

    select any(p.p_name) as p_num, any(p.tagline) as tagline, . . .
    

    To fix this, put all your current variables in a group by clause:

    GROUP BY
      p.p_name,
      p.id,
      cat.cat_name,
      p.property_type,
      p.p_type,
      p.address,
      c.client_name,
      p.price,
      pd.land_area,
      pd.land_area_rp,
      p.tagline,
      p.map_location,
      r.id,
      p.status,
      co.country_name,
      p.`show`,
      u.name,
      p.created_date,
      p.updated_dt,
      o.type_id,
      p.furnished,
      p.expiry_date 
    

    Most people who write SQL think it is good form to include all the group by variables in the group by clause, even though MySQL does not necessarily require this.

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

Sidebar

Related Questions

I will try to explain my problem clearly: I have two tables: document and
I will to try to explain this as best as I can. I have
I have a problem and I will try to explain the issue: I have
I will try to explain as best as I can what I realy want
I will try to explain the situation as it is a little bit more
I will try to explain a simple app scenario: My app goes right to
First I will try to explain what I want to do. The app loads
sorry for asking this dumb question i will try to explain as good as
Having trouble with each function... Will try to explain by example... In my code,
Background: I hope my question is not too vague. I will try and explain

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.