语句如下:
$sql="select c.cid,c.cname,p.uid from `biz_channel` c,`pre_common_member_profile` p where p.resideprovince=c.cname and c.cmod='area' group by c.cid";where p.resideprovince=c.cname  这里的条件我想改成like  也就是where p.resideprovince like c.cname
但是查询到的和用等于是相同的结果,正常应该比用“等于”查询到的结果更多才对。我也尝试用where p.resideprovince like '%c.cname%'   和 where p.resideprovince like %c.cname% 都不行。请问正确的应该怎么写??

解决方案 »

  1.   


    数据是像的,c.cname这里存的是 河北、四川、湖南…………这样的数据
     p.resideprovince 这里存的是 河北省、四川省、湖南省…………这样的,只能用like 查询
      

  2.   

    改成编程实现好了,不要把所有都搞到sql里面, 
      

  3.   

    $sql="select c.cid,c.cname,p.uid from `biz_channel` c,`pre_common_member_profile` p where p.resideprovince=c.cname and c.cmod='area' group by c.cid
    and where p.resideprovince like concat('%',c.cname,'%') ";
      

  4.   

    看到concat了。$sql="select c.cid,c.cname,p.uid from `biz_channel` c,`pre_common_member_profile` p where p.resideprovince like concat('%',c.cname,'%') and c.cmod='area' group by c.cid个人感觉其实你可用substring() ,或者left()
      

  5.   

    最后我还是用编程的方式完成了,全用sql做起来确实比较麻烦