sql - ORA-00904: "FOODSUPPLY"."FOODSUPPLYID": 标识符无效
问题描述
执行 INNER JOIN 时遇到 ORA-00904 错误。是什么原因以及如何解决?
Error : PL/SQL: ORA-00904:
"FOODSUPPLY"."FOODSUPPLYID": invalid
identifier
有多个(F1)Chicken,我只想要 DISTINCT 值
例如:(F1)在(S001)中只能出现一次,但在(S002)中仍然可以出现
SELECT s.shelterID,'('|| fs.foodSupplyID ||') '||fs.foodSupplyName AS foodSupplyDesc
FROM FoodSupply FS,Victim V,Shelter s,Shelter_allocation sa
INNER JOIN Request R ON Request.foodsupplyID = FoodSupply.foodSupplyID
WHERE r.victimID = v.victimID
AND fs.foodsupplyID = r.foodSupplyID
AND r.victimID=sa.victimID
AND SA.shelterID=s.shelterID
ORDER BY s.shelterID,requestDate;
电流输出:
shelterID | foodDesc
S001 | (F1)Chicken
S001 | (F3)Beef
S001 | (F1)Chicken
S002 | (F1)Chicken
S002 | (F5)Meat
S002 | (F1)Chicken
期望的输出:
shelterID | foodDesc
S001 | (F1)Chicken
| (F3)Beef
S002 | (F1)Chicken
| (F5)Meat
解决方案
您可以在下面尝试 - 您错过了别名
但是,最好使用显式连接
SELECT distinct s.shelterID,'('|| fs.foodSupplyID ||') '||fs.foodSupplyName AS foodSupplyDesc
FROM FoodSupply FS INNER JOIN Request R ON R.foodsupplyID = FS.foodSupplyID
Inner join Victim V on R.victimID = V.victimID
Inner join Shelter_allocation sa on R.victimID=sa.victimID
inner join Shelter s on sa.shelterID=s.shelterID
ORDER BY s.shelterID,requestDate
推荐阅读
- python - 当字符串中有浮点数时如何过滤值
- javascript - 为什么我的 javascript 它使用很长时间才能运行?
- xcode - TestFlight 和发布运行崩溃?
- php - 用 sdcc.domain.com 替换 sdcc.domain.com/admin 以触发 symfony 4 主页
- android - 无法允许用户一次选中一个复选框
- python-3.x - 如何在 Gunicorn 启动它的主进程之前触发一个函数
- c# - 解析具有不同行号的 HTML 表格
- mkmapview - “UIViewController”类型的值没有成员“mapView”;你是说'loadView'吗?
- javascript - 我在以下 chai 期望中收到断言错误
- typescript - 有没有办法告诉 TypeScript 在生成声明文件时排除模块?