select room.roomtype,inhotel.innum,worker.workname from room -> join inhotel on inhotel.roomnum=room.roomnum join (select workname from worker)workname on inhotel.worknum=worker.worknum; ERROR 1054 (42S22): Unknown column 'worker.workname' in 'field list'
时间: 2024-02-28 22:57:20 浏览: 97
Unknown column ” in ‘field list’解决方案
5星 · 资源好评率100%
根据你提供的 SQL 语句,错误提示是无法识别 "worker.workname" 这个列名,这是因为你在子查询中创建了一个名为 "workname" 的子查询表,但你没有给它一个别名,所以在主查询中无法引用它。
可以尝试修改 SQL 语句,给子查询表 "workname" 添加一个别名,例如:
```
SELECT room.roomtype, inhotel.innum, w.workname
FROM room
JOIN inhotel ON inhotel.roomnum = room.roomnum
JOIN (SELECT workname FROM worker) AS w ON inhotel.worknum = w.worknum;
```
这样应该可以解决问题。
阅读全文