У меня есть запрос для получения данных из нескольких таблиц. Но каким-то образом я получил повторяющиеся записи из базы данных из-за одного столбца.
Запрос:
SELECT
BH.BusinessName, AppointmentStartTime, AppointmentEndTime, AppointmentStatus,
AppointmentFor, AppointmentForID, AppointmentStatus, S.ServiceName
from Appointment A
INNER JOIN BusinessHost BH ON A.BusinessHostID = BH.BusinessHostID
INNER JOIN BusinessHostService BHS ON BHS.BusinessHostID=BH.BusinessHostID
INNER JOIN Services S ON S.ServiceID=BHS.ServiceID
и вывод выглядит так:
+ -------------+----------------------+--------------------+-------------------+----------------+------------------+-------------------+---------------------+
| BusinessName | AppointmentStartTime | AppointmentEndTime | AppointmentStatus | AppointmentFor | AppointmentForID | AppointmentStatus | ServiceName |
+ -------------+----------------------+--------------------+-------------------+----------------+------------------+-------------------+---------------------+
| Amit & Sons | 02:00:00.0000000 | 02:15:00.0000000 | Added | Motor-Cycle | 1006 | Added | Arboriculture |
| Amit & Sons | 02:00:00.0000000 | 02:15:00.0000000 | Added | Motor-Cycle | 1006 | Added | Landscaping Service |
| Rohit & Sons | 02:30:00.0000000 | 02:45:00.0000000 | Added | Motor-Cycle | 1006 | Added | Arboriculture |
| Rohit & Sons | 02:30:00.0000000 | 02:45:00.0000000 | Added | Motor-Cycle | 1006 | Added | Landscaping Service |
+ -------------+----------------------+--------------------+-------------------+----------------+------------------+-------------------+---------------------+
можете ли вы помогите мне с написанием запроса, чтобы получить желаемые результаты, такие как:
+ -------------+----------------------+--------------------+-------------------+----------------+------------------+-------------------+------------------------------------+
| BusinessName | AppointmentStartTime | AppointmentEndTime | AppointmentStatus | AppointmentFor | AppointmentForID | AppointmentStatus | ServiceNames |
+ -------------+----------------------+--------------------+-------------------+----------------+------------------+-------------------+------------------------------------+
| Amit & Sons | 02:30:00.0000000 | 02:45:00.0000000 | Added | Motor-Cycle | 1006 | Added | Arboriculture, Landscaping Service |
| Rohit & Sons | 02:30:00.0000000 | 02:45:00.0000000 | Added | Motor-Cycle | 1006 | Added | Arboriculture, Landscaping Service |
+ -------------+----------------------+--------------------+-------------------+----------------+------------------+-------------------+------------------------------------+