MariaDB社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索

求助查询语法问题!求大腿帮忙

查看数: 3024 | 评论数: 3 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2013-6-4 16:55

正文摘要:

select * from p_ecms_movie where isgood=9 and classid='59' or classid='60' or classid='62' order by newstime desc limit 10复制代码明明已经用isgood=9查询了..可为什么还是能查询到isgood=0的数据..请问哪里 ...

回复

kevin_mariadb 发表于 2015-11-3 14:13:22
那么多的or ,当然会是这个结果。
lsmir2 发表于 2015-6-27 00:15:28
本帖最后由 lsmir2 于 2015-6-27 00:20 编辑

你用了 or
select * from p_ecms_movie where isgood=9 and classid='59' or classid='60' or classid='62' order by newstime desc limit 10
条件  是 isgood=9 与 classid='59'  或者  classid='60'   or classid='62'    
满足 isgood=9 与 classid='59'   的返回  
满足   classid='60'   or classid='62' 也返回
最后再分组 排序
kider 发表于 2013-6-4 17:54:07
语句中没有括号,又有这么多or,当然了。
按照查询目的,适当加括号解决。

QQ|Archiver|小黑屋|手机版|MariaDB社区 ( 京ICP备07012489号    |
业务联系: QQ:48474881; 邮箱: 48474881@qq.com; 电话:13911732319
声明:本站部分文章是网友转载,若未经作者同意或署名有误,请联系网站管理员。

GMT+8, 2024-9-20 00:24 , Processed in 0.066224 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表