加入我想在mysql中加入一個查詢的輸出與第二個表:與內部問題在MySQL
(select
A.name, A.address, sum(C.penalty_points) as points
from
restaurant as A
inner join
inspection as B ON A.restaurant_id = B.restaurant_id
inner join
violation as C ON C.violation_id = B.violation_id
group by A.name)
輸出:
name address points
Kitchen 305 660 Washington Ave 2
PL8 Kitchen Southeast 17th Street in Fort Lauderdale 11
Prime One Twelve 112 Ocean Drive 5
Seasons 52 Palm Beach Gardens 3
Six Tables 32 East Atlantic 8
Table 26 Park Racks Downtown Eatery 2
第二個表的結果:
select * from health_points
輸出:
points health_grade
0 A
1 A
2 A
3 A
4 A
5 B
6 B
7 B
8 B
9 B
10 B
11 C
12 C
13 C
14 C
15 C
17 FAIL
18 FAIL
19 FAIL
有沒有一種方法可以將第一個查詢與第二個表相結合並提取健康等級?我正在嘗試這樣的:
(select
A.name, A.address, sum(C.penalty_points) as points
from
restaurant as A
inner join
inspection as B ON A.restaurant_id = B.restaurant_id
inner join
violation as C ON C.violation_id = B.violation_id
group by A.name) as D inner join health_points as E on D.points = E.points
但它顯示錯誤在MySQL?任何指向哪裏我會錯在這裏?
@Thorsten你是如何刪除所有的演員逗號這麼容易?並放置列? – python
我已經使用過一個文本編輯器:-) –
@我可以給你一個大拇指:)或積分 – python