同一表MySQL5.6.4的子查询中“where子句”中的未知列“ats2”

jrcvhitl  于 2021-06-18  发布在  Mysql
关注(0)|答案(0)|浏览(137)
SELECT *, (
    CASE WHEN ats1.time_slot_id = 48
    THEN 1
    ELSE ats1.time_slot_id
    END
  ) AS temp_time_slot_id,
  (
    SELECT id
    FROM allocated_time_slot
    WHERE from_time >= '2018-10-11 06:25:40'
    AND patient_id IS NULL
    AND doctor_id = '1167'
    AND time_slot_id = temp_time_slot_id
  ) AS ats2
FROM allocated_time_slot AS ats1
WHERE ats1.doctor_id = '1167'
AND ats1.from_time >= '2018-10-11 06:25:40'
AND ats1.patient_id IS NULL
AND ats2 IS NOT NULL
LIMIT 1

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题