Remove the GROUP BY
.
SELECT w.id, w.title, i.imPath
FROM works w
LEFT JOIN images i ON w.id=i.work_id
WHERE w.isActive=1
ORDER BY w.ordr
That should give you all rows you desire.
Another way to look at it:
create table works(id int, title varchar(10));
insert into works values (1, 'hello'), (2, 'world');
create table images(id int, work_id int, impath varchar(100))
insert into images values (1, 1, '/data/hello1.png'), (2, 1, '/data/hello2.png'), (3, 2, '/data/world1.png');
Works
id | title
1 | hello
2 | world
Images
id | work_id | impath
1 | 1 | /data/hello1.png
2 | 1 | /data/hello2.png
3 | 2 | /data/world1.png
Which can be translated to something like this in your case:
SELECT w.id, w.title,
GROUP_CONCAT(DISTINCT i.imPath ORDER BY i.imPath SEPARATOR ',') AS images
FROM works w
LEFT JOIN images i ON w.id=i.work_id
WHERE w.isActive=1
GROUP BY w.id, w.title
ORDER BY w.ordr
Result:
id | title | images
1 | hello | /data/hello1.png,/data/hello2.png
2 | world | /data/world1.png
SQLFiddle example: http://sqlfiddle.com/#!9/b5784c/1
To get caption of the image as well, you could do something like this:
SELECT w.id, w.title,
GROUP_CONCAT(
DISTINCT CONCAT(i.imPath,'|',i.caption)
ORDER BY CONCAT(i.imPath,'|',i.caption)
SEPARATOR ',') AS images
FROM works w
LEFT JOIN images i ON w.id=i.work_id
WHERE w.isActive=1
GROUP BY w.id, w.title
ORDER BY w.ordr