The query will retrieve IDs and all Attachment IDs as inline values like this
ID | Attachments
26| 299,300,301,10922,11286,45927,45939
63| 299,300,301,10922,11286,45927,45939
73| 299,300,301,10922,11286,45927,45939
91| 299,300,301,10922,11286,45927,45939
103| 299,300,301,10922,11286,45927,45939
As you can see, the list for attachments repeats itself since I hardcoded it to fetch WHERE pl_posts.post_parent = 26
. How can I change this hardcoded value so that it finds all attachment for that row post ID? If I replace that line to WHERE pl_posts.post_parent = pl_posts.ID
I get NULL for everything so I am not sure if this is right?
SELECT
SQL_CALC_FOUND_ROWS pl_posts.ID,
(
SELECT GROUP_CONCAT(pl_posts.ID)
FROM pl_posts
WHERE pl_posts.post_parent = 26
AND pl_posts.post_type = 'attachment'
ORDER BY pl_posts.post_date DESC
) AS Attachments
FROM pl_posts
GROUP BY pl_posts.ID
LIMIT 0, 25