gpt4 book ai didi

mysql - 查找 LIKE 值,但排除 mySQL 中的已知项

转载 作者:行者123 更新时间:2023-11-29 01:00:20 24 4
gpt4 key购买 nike

有没有一种方法可以搜索相关帖子的帖子标签,但从显示结果中排除正在搜索的帖子?如果是这样怎么办?我会将代码放在查询中的什么位置?

这是我到目前为止得到的结果。

SELECT *
FROM users_posts
WHERE users_posts.title LIKE '%$search_tag%' OR users_posts.summary LIKE '%$search_tag%' OR users_posts.content LIKE '%$search_tag%'
ORDER BY RAND()
LIMIT 5

最佳答案

只需在 WHERE 子句中添加如下内容即可删除当前帖子:

and users_posts.id <> @CurrentPostID

关于mysql - 查找 LIKE 值,但排除 mySQL 中的已知项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3729569/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com