一句简单的SQL语言,出错了,帮我改改!!!
select count(*) from view_user where year(birthday)=1975 or year(birthday)=1981 and expire_date>'2004-12-01 00:00:00' and expire_date<'2004-12-31 00:00:00' and gold>=1 and location=100 结果比正常的差太多,估计是错了,
select count(*) from view_user where year(birthday)=1975 and expire_date>'2004-12-01 00:00:00' and expire_date<'2004-12-31 00:00:00' and gold>=1 and location=100 结束正确
第二句中我把or year(birthday)=1981删了,就正确了,
可能是and 和or 不能一起这么用???
应该怎么做???
问题点数:20、回复次数:4Top
1 楼wfhlad(我爱rae)回复于 2004-12-02 19:55:25 得分 0
自己先顶一下
Top
2 楼yingqing(曾明)回复于 2004-12-02 20:04:01 得分 15
and 的優先級別高於or ,你的語句相當於 select count(*) from view_user where( year(birthday)=1975) or( year(birthday)=1981 and expire_date>'2004-12-01 00:00:00' and expire_date<'2004-12-31 00:00:00' and gold>=1 and location=100)Top
3 楼handycyw(xmccc)回复于 2004-12-02 20:09:15 得分 5
同意楼上的。注意括号的使用。Top
4 楼wfhlad(我爱rae)回复于 2004-12-02 20:12:20 得分 0
谢谢,结了Top




