I have two tables, they are properties and property_images. The fields in properties table are as below
SELECT *, photo, COUNT(property_photo.photo) as photocount
FROM properties LEFT JOIN
ON properties.property_id = property_photo.property_id
GROUP BY properties.property_id
You can use
SELECT p.*, COUNT(pp.photoname) as photocount, GROUP_CONCAT(pp.photoname SEPARATOR '|') FROM properties p LEFT JOIN property_photo pp ON p.property_id = pp.property_id GROUP BY p.property_id LIMIT 6;
This puts the names of the photos in a string, with a vertical bar separating each name.