猿问

你好,求解,关于在mysql中用like实现多条件模糊查询?内容太多,请看下面

SELECT BigCategory
,SmallCategory,Model_No
,1 'yuefen'
,SUM(case when BizType='P' then MONTH1Num end ) as P
,SUM(case when BizType='S' then MONTH1Num end ) as S
,SUM(case when BizType='I' then MONTH1Num end ) as I
,SUM(case when BizType='P' then MONTH1Num end )- SUM(case when BizType='S' then MONTH1Num end )-SUM(case when BizType='I' then MONTH1Num end ) PanDian
FROM t_test
WHERE Model_No like 'iphone4s%'
OR WHERE Model_No like 'v480%'
SELECT BigCategory
,SmallCategory,Model_No
,1 'yuefen'
,SUM(case when BizType='P' then MONTH1Num end ) as P
,SUM(case when BizType='S' then MONTH1Num end ) as S
,SUM(case when BizType='I' then MONTH1Num end ) as I
,SUM(case when BizType='P' then MONTH1Num end )- SUM(case when BizType='S' then MONTH1Num end )-SUM(case when BizType='I' then MONTH1Num end ) PanDian
FROM t_test
WHERE Model_No like 'iphone4s%'
OR WHERE Model_No like 'v480%'
GROUP BY BigCategory,SmallCategory,Model_No;

我这段代码为什么老是报错,用的是mysql数据库

眼眸繁星
浏览 394回答 2
2回答

红糖糍粑

你的代码 有两个 whereWHERE Model_No like 'iphone4s%'OR WHERE Model_No like 'v480%'改成这样WHERE Model_No like 'iphone4s%'OR Model_No like 'v480%'

幕布斯7119047

select * from mm where name like '王%' or name like '张%' or name like '李%'或者select name from table where name like '王%'unionselect name from table where name like '张%'unionselect name from table where name like '李%'
随时随地看视频慕课网APP
我要回答