Hãy thử cái này:
SELECT hotels.hotelID,
hotels.hotelName,
GROUP_CONCAT(operators.opName SEPARATOR ', ') AS opList
FROM hotels
INNER JOIN operators
ON operators.opHotelID = hotels.hotelID
GROUP BY(hotels.hotelID)
Nếu bạn muốn có số lượng toán tử, bạn phải sử dụng COUNT trên ID toán tử như sau:
SELECT hotels.hotelID,
hotels.hotelName,
GROUP_CONCAT(operators.opName SEPARATOR ', ') AS opList,
COUNT(operators.opID) AS nbOperatos
FROM hotels
LEFT JOIN operators
ON operators.opHotelID = hotels.hotelID
GROUP BY(hotels.hotelID)