Sql语句 查询条件的问题 高手低手都请进

hycapril 2004-06-23 04:22:39
一个表q
有字段 a b c
1 2 8
1 3 9
1 4 7
0 2 6
现在想得到结果 a=1 b=2 和 3
a b c
1 2 8
1 3 9
select * from q where a='1' and b=2 or b=3
不好用。

...全文
89 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Vicky79 2004-06-29
  • 打赏
  • 举报
回复
select * from q where a=1 and (b=2 or b=3)
饮水需思源 2004-06-24
  • 打赏
  • 举报
回复
select * from q where a='1' and b in('2','3')
zoubsky 2004-06-24
  • 打赏
  • 举报
回复
select * from q where (b=2 or b=3) and a='1'
hycapril 2004-06-23
  • 打赏
  • 举报
回复
select * from q where a='1' and (b='2' or b='3')
好用 给分了
谢谢 trampwind(随风)
trampwind 2004-06-23
  • 打赏
  • 举报
回复
你把他们的运算关系弄乱了,and优先级高于or的,这样看看:
select * from q where a='1' and (b=2 or b=3)

7,714

社区成员

发帖
与我相关
我的任务
社区描述
Microsoft Office Access是由微软发布的关系数据库管理系统。它结合了 MicrosoftJet Database Engine 和 图形用户界面两项特点。
社区管理员
  • Access
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧