Qns :项目描述和任何名为Jessie Stange的患者的治疗日期(即GivenName是Jessie& FamilyName是Stange)
我写的:
SELECT DISTINCT Description, Date as treatmentDate
WHERE doothey.Patient P, doothey.Account A, doothey.AccountLine AL, doothey.Item.I
AND P.PatientID = A.PatientID
AND A.AccountNo = AL.AccountNo
AND AL.ItemNo = I.ItemNo
AND (p.FamilyName = 'Stange' AND p.GivenName = 'Jessie');
错误:
Error at Command Line:1 Column:30
Error report:
SQL Error: ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:
*Action:
缺少什么表达?
答案 0 :(得分:10)
您的语句正在调用SELECT和WHERE,但未指定您要选择哪个TABLE或记录集。
SELECT DISTINCT Description, Date as treatmentDate
FROM (TABLE_NAME or SUBQUERY)<br> --This is missing from your query.
WHERE doothey.Patient P, doothey.Account A, doothey.AccountLine AL, doothey.Item.I
AND P.PatientID = A.PatientID
AND A.AccountNo = AL.AccountNo
AND AL.ItemNo = I.ItemNo
AND (p.FamilyName = 'Stange' AND p.GivenName = 'Jessie');
答案 1 :(得分:2)
你犯了两个错误。我认为你错放了FROM和WHERE关键字。
SELECT DISTINCT Description, Date as treatmentDate
FROM doothey.Patient P, doothey.Account A, doothey.AccountLine AL, doothey.Item.I --Here you use "." operator to "I" alias
WHERE -- WHERE should be located here.
P.PatientID = A.PatientID
AND A.AccountNo = AL.AccountNo
AND AL.ItemNo = I.ItemNo
AND (p.FamilyName = 'Stange' AND p.GivenName = 'Jessie');
答案 2 :(得分:0)
在上面的查询中,当我们尝试组合两个或多个表时,必须使用连接并指定描述和日期的别名(即,从中获取描述和日期值的表)< / p>
SELECT DISTINCT Description, Date as treatmentDate
FROM doothey.Patient P
INNER JOIN doothey.Account A ON P.PatientID = A.PatientID
INNER JOIN doothey.AccountLine AL ON A.AccountNo = AL.AccountNo
INNER JOIN doothey.Item I ON AL.ItemNo = I.ItemNo
WHERE p.FamilyName = 'Stange' AND p.GivenName = 'Jessie';
答案 3 :(得分:0)
您没有对表使用 FROM 表达式
SELECT DISTINCT Description, Date as treatmentDate
**FROM <A TABLE>**
WHERE doothey.Patient P, doothey.Account A, doothey.AccountLine AL, doothey.Item.I
AND P.PatientID = A.PatientID
AND A.AccountNo = AL.AccountNo
AND AL.ItemNo = I.ItemNo
AND (p.FamilyName = 'Stange' AND p.GivenName = 'Jessie');
答案 4 :(得分:-2)
1 select ename as name, 2 sal as salary, 3 dept,deptno, 4 from (TABLE_NAME or SUBQUERY) 5 emp, emp2, dept 6 where 7 emp.deptno = dept.deptno and 8 emp2.deptno = emp.deptno 9* order by dept.dname from (TABLE_NAME or SUBQUERY) * ERROR at line 4: ORA-00936: missing expression` select ename as name, sal as salary, dept,deptno, from (TABLE_NAME or SUBQUERY) emp, emp2, dept where emp.deptno = dept.deptno and emp2.deptno = emp.deptno order by dept.dname`