Вашето запитване:
SELECT Email, Phonenumber
FROM EMPLOYEE
WHERE COUNT(
ID = (SELECT ID_Num
FROM SCHEDULE
WHERE Start_Time <= 12:07 AND End_Time >= 12:07)
AND Shopn = (SELECT Shopname
FROM SHOP
WHERE Shoptype = ‘market’) ) > 2
Проблеми :
- Изглежда, че се опитвате да изберете идентификатор с помощта на оператор "=", който ще се провали в случай на множество записи, върнати от вътрешна заявка.
- Не можете да добавяте обобщени оператори в клаузата where.
Вероятен отговор:
select Email, Phonenumber
FROM EMPLOYEE
WHERE ID in (SELECT ID_Num
FROM SCHEDULE
WHERE Start_Time <= '12:07' AND End_Time >= '12:07')
AND Shopn in (SELECT Shopname
FROM SHOP
WHERE Shoptype = 'market')
and (
select count(distinct id)
FROM EMPLOYEE
WHERE ID in (SELECT ID_Num
FROM SCHEDULE
WHERE Start_Time <= '12:07' AND End_Time >= '12:07')
AND Shopn in (SELECT Shopname
FROM SHOP
WHERE Shoptype = 'market')) > 2;