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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:17:36+00:00 2026-06-08T16:17:36+00:00

When I use the following query without LIMIT nested in a subquery SELECT `c`.*,

  • 0

When I use the following query without LIMIT nested in a subquery

SELECT   `c`.*, 
         GROUP_CONCAT(g.photo SEPARATOR "|") AS `photos_list` 
  FROM   `contests` AS `c` 
              LEFT JOIN 
                  (
                      SELECT   `gallery`.`contest_id`, 
                               `gallery`.`photo` 
                        FROM   `gallery`
                   ) AS `g` ON c.id = g.contest_id 
GROUP BY `c`.`id`

all works fine

id   title    photos_list 

1    title1   50026c35632eb.jpg
2    title2   50026ac53567f.jpg|50026ac5ec82e.jpg|500e71557270f....

Bun when I add LIMIT, I get “photos_list” in only one row. Following query

SELECT   `c`.*, 
         GROUP_CONCAT(g.photo SEPARATOR "|") AS `photos_list` 
  FROM   `contests` AS `c` 
              LEFT JOIN 
                  (
                      SELECT   `gallery`.`contest_id`, 
                               `gallery`.`photo` 
                        FROM   `gallery`
                       LIMIT    0, 2
                   ) AS `g` ON c.id = g.contest_id 
GROUP BY `c`.`id`

will return

id  title   photos_list 

1   title1  NULL
2   title2  50026ac46ea05.jpg|50026ac53567f.jpg

Item with an id = 1 has to contain photos_list, but it doesn’t. Noteworthy that LIMIT does work for item with an id = 2.

What should I do to get a correct result?

  • 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-08T16:17:38+00:00Added an answer on June 8, 2026 at 4:17 pm
    SELECT   `c`.*, 
         GROUP_CONCAT(g.photo SEPARATOR "|") AS `photos_list` 
    FROM   `contests` AS `c` 
              LEFT JOIN 
                  (
                      SELECT   `gallery`.`contest_id`, 
                               `gallery`.`photo` 
                        FROM   `gallery`
                   ) AS `g` ON c.id = g.contest_id 
    GROUP BY `c`.`id`
    

    Change GROUP_CONCAT to this:

    SUBSTRING_INDEX(GROUP_CONCAT(g.photo SEPARATOR "|"),'|',2) AS `photos_list` 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following query (in a PHP script) SELECT *, (SELECT head FROM
for example i use following command to find a record SELECT `users`.`mail` FROM `users`
The following query returns data right away: SELECT time, value from data order by
I have the following sample query (MySQL): SELECT * FROM `action` WHERE `customer_id` IN
I have the following query: SELECT * from foo where timestamp = (select max(timestamp)
I have the following query: $result = mysql_query("SELECT option_value FROM wp_10_options WHERE option_name='homepage'"); $row
I have the following query: SELECT patient_id FROM patient_visit where visit_type in ('A', 'B',
I use the following query to get a result set var overlaps = from
Given the following query: SELECT M.year, COUNT(C.eid) FROM Card AS C, Month AS M
So I have the following query: IF ( ( SELECT RevisionNumber FROM SchemaVersion )

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.