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

关于select in的问题
我写了如下的两条SQL语句:
 SELECT count(*) FROM Topics WHERE AND SectionID in ('ID1, ID2')

 SELECT count(*) FROM Topics WHERE AND SectionID in ('ID2, ID1')
按理说,两条语句执行结果应该是一样的,但是结果不一样
 
SELECT count(*) FROM Topics WHERE AND SectionID in ('ID1, ID2')的结果和
SELECT count(*) FROM Topics WHERE AND SectionID in ('ID1')一样

SELECT count(*) FROM Topics WHERE AND SectionID in ('ID2, ID1')的结果和
SELECT count(*) FROM Topics WHERE AND SectionID in ('ID2')一样

不太明白为什么,请大家解释一下



------解决方案--------------------
寫法應該是:
SELECT count(*) FROM Topics WHERE AND SectionID in ( 'ID1', 'ID2')