码迷,mamicode.com
首页 > 数据库 > 详细

MySQL遇到经典例子--(遇到就写)

时间:2017-09-16 12:00:35      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:content   from   搜索   情况   div   use   例子   style   rom   

1,一般的搜索只会搜索标题,也有特殊的情况,就是标题和内容一起搜索!

1 -- 模糊搜索只是搜索标题
2 $sql = "select count(*) as sum from publish where pub_title like %{$keyword}% or pub_content like %{$keyword}%";
3 
4 -- 模糊搜索搜索标题和内容
5 $sql = "select * from publish left join user on pub_owner = user_name where pub_title like %{$keyword}% or pub_content like %{$keyword}% order by pub_time desc limit $offset, $rowsPerPage";

 

MySQL遇到经典例子--(遇到就写)

标签:content   from   搜索   情况   div   use   例子   style   rom   

原文地址:http://www.cnblogs.com/mrszhou/p/7529915.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!