日期:2014-05-18  浏览次数:20458 次

新手求一个简单的的表达式(在线等,马上结贴送分)
select   *   from   Forums_Posts   where   SortOrder=1   and   PostType=1   and   UserID=5   and   ForumID=45   or   ForumID=44   order   by   PostID   desc

其中用ForumID=45   or   ForumID=44条件的话   不想查询出来的条件都会被查询出来

用ForumID=45   and   ForumID=44   的话又什么都查不出来

请问下高手这句需要怎么写才正确?   也就是同一个字段需要提出包含44.45两个条件的数据

------解决方案--------------------
--使用()

select *
from Forums_Posts
where SortOrder=1 and PostType=1 and UserID=5 and (ForumID=45 or ForumID=44)
order by PostID desc