MySQL 中 and 和 or 的组合使用

引用博文:https://www.cnblogs.com/ryanzheng/p/7894688.html

在 代码中 需要对 用户的某个字段过滤   SQL:

SQL1:

 SELECT count(1) FROM img_chart_def d where  d.chart_name like '%'  and d.chart_class = 'consumeContribution';

 

SQL2:

SELECT COUNT(1) FROM img_chart_def d where d.chart_class = 'consumeContribution' and ( d.chart_name like '会%'
OR d.chart_name like 'A%' OR d.chart_name like '最%' OR d.chart_name like '品%' OR d.chart_name like '购%'

or d.chart_name like '测%' OR d.chart_name like 'c%' OR d.chart_name like '注%' OR d.chart_name like '性%'
OR d.chart_name like '生%'
OR d.chart_name like '星%' OR d.chart_name like '各%'

OR d.chart_name like '所%'
OR d.chart_name like '报%' OR d.chart_name like '参%' OR d.chart_name like '服%' or d.chart_name like '会%');

posted @ 2020-01-12 23:22  牧の风  阅读(818)  评论(0编辑  收藏  举报