SQl声明总和

时间:2012-04-10 23:20:44

标签: mysql

嘿伙计们,我试图总结这些表格,我无法弄清楚我做错了什么

我的第一张表是:

Reserve
ReserveID   MembershipID   PlayerCount   Time    CourseID

我的第二张表是

Courses
CourseID   Name

我正在尝试的sql语句在这里:

Select Sum(Reserve.Player_Count)Total
From Reserve 
Left Join Courses 
On Courses.CourseID = Reserve.ReserveID 
Where Time = "2012-04-09 07:10:00" 
And Courses.Name = "Lake" (or I had Courses.CourseId = "1")

1 个答案:

答案 0 :(得分:0)

你似乎在混合别名。避免他们

Select Sum(Reserve.Player_Count)Total
From Reserve 
Left Join Courses 
On Courses.CourseID = Reserve.ReserveID 
Where Reserve.Time = "2012-04-09 07:10:00" 
--     ^ Right here  
And Courses.Name = "Lake" (or I had Courses.CourseId = "1")