Query using group_concat is returning only one row
When I try to use group_concat it just returns me one row and I do not understand why.
Because you have not used the GROUP BY
clause in your query. When using aggregate functions like GROUP_CONCAT
you need to tell the database about the column using which you want your data to be combined.
Currently your query is grouping all records and giving 1 record in the output.
If you add GROUP BY users.userid
in the query then the records will be grouped by unique userid's. I updated your fiddle and it now gives 2 records: http://www.sqlfiddle.com/#!2/867f6/18
Please note: In standard SQL queries, columns listed in the GROUP BY clause should match the column in the SELECT clause (except the aggregate functions).
Just use group by
clause in your_query
SELECT users.first_name, users.last_name,
users.user_id, projects.project_id,
projects.project_name, projects.project_time,
group_concat(images.image_path)
FROM users, projects, images
WHERE users.user_id = projects.user_id
AND users.user_id IN (SELECT follow_user_2 FROM following
WHERE follow_user_1 = 1)
group by users.first_name
ORDER BY projects.project_id DESC;
fiddle