我想通过我的Membership
表查询以获取某个成员的结果,但是我得到了错误的结果。这是我的疑问:
select MemNo, MemDOB, MemberType, MemShrBal
From Membership
Where MemberType = 1 or MemberType = 2
and MemDOB > '1973/12/31'
and MemShrBal = 250.00
任何人都可以帮我找出原因:除了正确的成员记录外,我还会获得MemShrBal
超过250.0和{{1}的成员记录下面' 1973'?
答案 0 :(得分:9)
你需要一些括号:
select MemNo, MemDOB, MemberType, MemShrBal
From Membership
Where (MemberType = 1 or MemberType = 2)
and MemDOB > '1973/12/31'
and MemShrBal = 250.00
and
比or
绑定得更紧,所以没有括号,它就是
MemberType = 1
or
MemberType = 2
and MemDOB > '1973/12/31'
and MemShrBal = 250.00