表1 phpcms_guanjianci字段如下:id title other weizhi
-----------------表2 wp_posts字段如下:id post_title------------------- 现在需要制作这么一个php文件,当运行的时候 就会实现: 表1的title里面的title内容 去全部匹配 表2里面的post_title内容。当这个结果大于3的时候(就是说表2有至少3篇文章包含这个关键词),那么将表1的字段weizhi 这里自动填写上ok,我是个超级大菜鸟,请论坛上的高手给分析下如何弄,谢谢了。
--------------------
举例:45 girls
46 boys
47 man就是girls、boys、man 表1中所有的关键词 去匹配第二个表的文章,当发现至少3篇文章包含这个关键词的时候 那么就将表1weizhi字段 写上ok
-----------------表2 wp_posts字段如下:id post_title------------------- 现在需要制作这么一个php文件,当运行的时候 就会实现: 表1的title里面的title内容 去全部匹配 表2里面的post_title内容。当这个结果大于3的时候(就是说表2有至少3篇文章包含这个关键词),那么将表1的字段weizhi 这里自动填写上ok,我是个超级大菜鸟,请论坛上的高手给分析下如何弄,谢谢了。
--------------------
举例:45 girls
46 boys
47 man就是girls、boys、man 表1中所有的关键词 去匹配第二个表的文章,当发现至少3篇文章包含这个关键词的时候 那么就将表1weizhi字段 写上ok
解决方案 »
- PHP写的server端,如何接收手机客户端传来的json数据
- 网站乱码问题
- PHP交流群 200人高级群:85758199
- 如何判断一个字串里面有两个 "Yes"字符的
- 几百M的文本文件(每行记录一条数据),有什么软件或者方法可以把它分割成几个文件
- 帝国备份王(Ebak)1.1正式版发布并提供下载
- 有哪位接触过sina,tom这样网站的专题发布系统?分不够可以再加
- php中得到本页url的方法是什么?
- 唉,写php程序都快2年了,真的觉得做网站赚钱都是小钱,而且赚钱也不是容易,大家有没有接单子自己做的,交流一下经验啊,
- PHP怎么这么厉害
- Warning: file_get_contents() 的问题
- 请虚心请教一个关于 PHP读取XML的问题,我死活就读不出来
"当这个结果大于3的时候(就是说表2有至少3篇文章包含这个关键词)"
这个..."大于3" 和 "至少3篇" ... 是不一样的:)
如果"至少3篇", 那么
update phpcms_guanjianci g
join wp_posts p
on p.post_title=g.title
set g.weizhi='ok'
group by g.title
having count(*)>=3 如果"大于3",那就改成>3
你好 ~以下是我根据你的代码写的
<?php
include("conn.php");
$sql="update phpcms_guanjianci g join wp_posts p on p.post_title=g.title set g.weizhi='ok' group by g.title having count(*)>=3 ";
if (!mysql_query($sql,$conn))
{
die('Error: ' . mysql_error());
}
echo "成功添加!";mysql_close($conn);
?> ------------------
但是提示错误----------Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group by g.title having count(*)>=3' at line 1
换这个
update phpcms_guanjianci
set weizhi='ok'
where title in (
select post_title
from wp_posts
group by post_title
having count(*)>=3
)
;
include("conn.php");
$sql="update phpcms_guanjianci set weizhi='ok' where title in (select post_title from wp_posts group by post_title having count(*)>=1)";if (!mysql_query($sql,$conn))
{
die('Error: ' . mysql_error());
}
echo "成功批量修改!";mysql_close($conn);
?> ------------------------------问题是这样的:phpcms_guanjianci的数据表 id title weizhi
5 Basic Financial Accounting for the Layman ok
6 Basic
-------------
您看明白了么? "Basic"这个关键词 按理论说的话 应该也会匹配的 对吧 但是他只是被整个句子的 就是"Basic Financial Accounting for the Layman" 整个才能写为 ok
你的关键词是用空格分隔的长字符串?
post_title应该就是文章标题?如果这样的话比较麻烦,要写存储过程或者放在php里处理
你好 大哥 不是这个意思以下是我的phpcms_guanjianci 经过这个php文件处理后的表的数据:
id title weizhi
17 Basic
16 Basic Financial Accounting for the Layman ok
14 Basic Financial
15 Basic Financial2
13 Basic Financial
--------------------------我用这些去匹配 后 只有那个Basic Financial Accounting for the Layman 这个跟另外一个表的标题一摸一样才写成OK 这样就没意思了吧我想是搜索啊 就是这个句子包含了 Basic 就行啊 你再帮看看 应该加上个like 什么的。?