56,678
社区成员
发帖
与我相关
我的任务
分享
create table t_user
(
ID int(11) not null auto_increment ,
userName varchar(64) default ' ',
userInfo varchar(32) default ' ',
Notes varchar(32) default ' ',
primary key (ID)
);
insert into t_user VALUES('张山','我是张山','小王亲戚'); -- 1
insert into t_user VALUES('李四','小王朋友','李四大大啊');-- 2
insert into t_user VALUES('王五','我是王五','小王就是我');-- 3
insert into t_user VALUES('刘六','我是刘六','刘六是我');-- 4
insert into t_user VALUES('刘七','我是刘七','小七');-- 5
insert into t_user VALUES('刘八','我是刘八','别叫我王八');-- 6
insert into t_user VALUES('刘九','小九','小八是蛋');-- 7
insert into t_user VALUES('张十','我是张十','小王很丑'); -- 8
select a.ID AS ProductID,a.NameCode,a.Name_cn,a.Name_en,p.PicName,a.BarCode,a.NewLevel,a.Status,a.HighPrice,d.SalesPlaceID FROM ProductInfo a left JOIN (SELECT ProductID,PicName FROM ProductPic where Sort = 1) as p ON a.ID = p.ProductID left join (select ProductID,SalesPlaceID from Channel_Product_Mapping WHERE SalesPlaceID = 2 GROUP BY ProductID) d on a.ID = d.ProductID where 1 = 1 or a.ID ='%test%' or a.Name_cn = '%test%' or a.NameCode ='%test%' or a.BarCode like '%test%' GROUP BY a.ID ORDER BY a.ID DESC LIMIT 0,25;-- 查询的是全部数据 和没有 or 是一样
-- 然后改成
select a.ID AS ProductID,a.NameCode,a.Name_cn,a.Name_en,p.PicName,a.BarCode,a.NewLevel,a.Status,a.HighPrice,d.SalesPlaceID FROM ProductInfo a left JOIN (SELECT ProductID,PicName FROM ProductPic where Sort = 1) as p ON a.ID = p.ProductID left join (select ProductID,SalesPlaceID from Channel_Product_Mapping WHERE SalesPlaceID = 2 GROUP BY ProductID) d on a.ID = d.ProductID where a.ID ='%test%' or a.Name_cn = '%test%' or a.NameCode ='%test%' or a.BarCode like '%test%' GROUP BY a.ID ORDER BY a.ID DESC LIMIT 0,25
-- 把 1=1 去掉后 就没有数据了