select *
from t_user
where userName like '%王%' or userInfo like '%王%' or Notes like '%王%';

解决方案 »

  1.   


    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 去掉后 就没有数据了
      

  2.   

    1=1永远成立 or后面的不起作用  肯定是全部数据先left一个表  看看有无数据
      

  3.   


    我错了。我一开始就错了。因为sql是修改过来的。有几个地方没有修改到。谢谢版主 耐心帮忙了。