我想要从数据表中抓取数据行,其中一个单词与我的列'story'中的文本内的某个单词匹配。检查与MySQL查询的字符串匹配
表结构:
post_id | user_id | story
----------------------------------
1 | 1 | Hello World What's up?
2 | 4 | Hello guys!
3 | 7 | Working on shareit.me!
例如:
我想抓住所有含你好(我找不区分大小写)字的帖子。
我该怎么做?
这是我迄今所做的:
// this will be the keyword! so use the variable $filter_tag in the query!
$filter_tag= $_GET['tag'];
//query for getting the users' posts containing the select tag
$query_posts= "SELECT * FROM posts WHERE user_id= '$user_id' ORDER BY post_id
DESC";
$result_posts= mysqli_query($connect, $query_posts);
谢谢!
那是一个错误的评论。查询是**不是**选择包含标签的用户的所有帖子,而是选择用户的所有帖子。 – 2013-05-03 13:02:22
你喜欢运营商尝试吗?一个基本的运营商应该为你做这件事。记住朋友基本知识是地下室 – 2013-05-03 13:03:06
我想你应该做一些关于如何做到这一点的搜索结果。以这种方式查询是SQL最基本的功能之一。 – Chad 2013-05-03 13:04:30