我正在尝试将旧样式查询转换为ANSI。为什么顶级查询失败(错误:ORA-00933:SQL命令未正确结束)但底部版本有效?
SELECT
JOBS.STARTED_DATE,
JOB_SCHEDULE_TECHNICIANS.EMPLOYEE_NUMBER,
JOB_SCHEDULE_TECHNICIANS.HOURS
FROM JOBS
JOIN JOB_SCHEDULE_TECHNICIANS ON JOB_SCHEDULE_TECHNICIANS.JOB = JOBS.JOB
WHERE
JOBS.STARTED_TIME BETWEEN to_date('2013-05-01', 'YYYY-MM-DD')
AND to_date('2013-05-03', 'YYYY-MM-DD')
SELECT
JOBS.STARTED_DATE,
JOB_SCHEDULE_TECHNICIANS.EMPLOYEE_NUMBER,
JOB_SCHEDULE_TECHNICIANS.HOURS
FROM JOBS, JOB_SCHEDULE_TECHNICIANS
WHERE
JOBS.STARTED_TIME BETWEEN to_date('2013-05-01', 'YYYY-MM-DD')
AND to_date('2013-05-03', 'YYYY-MM-DD')
AND JOB_SCHEDULE_TECHNICIANS.JOB = JOBS.JOB
答案 0 :(得分:2)
我认为上述 2 Query
中没有任何问题。
我建议将分号(;)作为 Mathew Strawbridge 评论。
像这样:
SELECT
JOBS.STARTED_DATE,
JOB_SCHEDULE_TECHNICIANS.EMPLOYEE_NUMBER,
JOB_SCHEDULE_TECHNICIANS.HOURS
FROM JOBS
JOIN JOB_SCHEDULE_TECHNICIANS ON JOB_SCHEDULE_TECHNICIANS.JOB = JOBS.JOB
WHERE
JOBS.STARTED_TIME BETWEEN to_date('2013-05-01', 'YYYY-MM-DD')
AND to_date('2013-05-03', 'YYYY-MM-DD')
; -- <- Here
SELECT
JOBS.STARTED_DATE,
JOB_SCHEDULE_TECHNICIANS.EMPLOYEE_NUMBER,
JOB_SCHEDULE_TECHNICIANS.HOURS
FROM JOBS, JOB_SCHEDULE_TECHNICIANS
WHERE
JOBS.STARTED_TIME BETWEEN to_date('2013-05-01', 'YYYY-MM-DD')
AND to_date('2013-05-03', 'YYYY-MM-DD')
AND JOB_SCHEDULE_TECHNICIANS.JOB = JOBS.JOB