SELECT TOP 5 Notices.Id, NoticeL.Notices_Id, Loc.Id as Location_Id,
CAST(Notices.Text AS TEXT) as Text, CAST(Notices.Title AS TEXT) as Title,
Notices.CDate as RegDate
FROM NoticeL JOIN Notices ON NoticeL.Notices_Id=Notices.Id
JOIN Loc ON NoticeL.Loc_Id=Loc.Id
WHERE Loc_Id IN (1) BETWEEN '06/04/2012' AND '23/04/2012'
我正在尝试在以下 IN 之间使用,但我没有运气。我收到以下语法错误:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'BETWEEN'.
我猜 MsSql 不喜欢这种语法。我怎样才能做到这一点?
第二个问题,我想在过去两周内过滤掉通知。无论如何我可以在mssql中动态地做到这一点。谢谢你的帮助。