2012-10-17 59 views
-2

希望有人可以給我一些指導。我查詢:在期望條件的上下文中指定的非布爾類型的表達式 - 錯誤

SELECT 
    wm.ID, 
    wm.name, 
    wm.meeting_type, 
    m.start_date, 
    wml.name as location 
FROM 
    webmaster.meeting wm inner join meetings m on wm.ID = m.Meeting_Code 
    inner join webmaster.meeting_location on wml wm.locationID = wml.ID 
WHERE 
    Year(m.start_date) = Year(getDate()) 
ORDER BY 
    m.start_date 

運行時,我得到這個錯誤:

Msg 4145, Level 15, State 1, Line 9 
An expression of non-boolean type specified in a context where a condition is expected, near 'wm'. 

有什麼我失蹤?

回答

5

改變這種從

inner join webmaster.meeting_location on wml wm.locationID = wml.ID 

to 

inner join webmaster.meeting_location wml on wm.locationID = wml.ID 
+0

謝謝你的第二雙眼睛! – etm124

+1

一致的代碼格式風格的價值在於這些類型的錯誤更容易吸引眼球。即將所有連接放在他們自己的路線上,這樣會更容易看到。 – Rawheiser

0

試試這個:

SELECT 
    wm.ID, 
    wm.name, 
    wm.meeting_type, 
    m.start_date, 
    wml.name as location 
FROM 
    webmaster.meeting wm inner join meetings m on wm.ID = m.Meeting_Code 
    inner join webmaster.meeting_location wml on wm.locationID = wml.ID 
WHERE 
    Year(m.start_date) = Year(getDate()) 
ORDER BY 
    m.start_date 
相關問題