基于标签选择相关标题,与mysql相似
标签 职位 我们如何才能在同一个post\u id中获得包含值基于标签选择相关标题,与mysql相似,mysql,sql,search,relevance,Mysql,Sql,Search,Relevance,标签 职位 我们如何才能在同一个post\u id中获得包含值的post\u id=1和2 所以结果是 post_id title ------------------- 1 some good title 2 some good 3 some 4 good title good titledosent显示,因为标签中的post\u id=4中没有某些值。 有些不符合要求良好尝试类似多次: RESULT title ----------
的post\u id=1和2
所以结果是
post_id title
-------------------
1 some good title
2 some good
3 some
4 good title
good title
dosent显示,因为标签中的post\u id=4中没有某些值。
有些
不符合要求良好
尝试类似
多次:
RESULT
title
----------
some good title
some good
您还可以这样连接两个表:
SELECT * FROM post
WHERE title LIKE '%some%'
AND title LIKE '%good%'
注意:如果我们不使用HAVING
子句,它还将返回存在任何单个值的记录
性能如何?我们能利用这些标签吗?或者我们最好不需要这样做?谢谢他,你能解释一下让count(*)1做什么吗?如果我们不使用having
,它也会给我们包含任何一个值(例如,一些,好)的记录,而不是having
它是你的帐户吗?不,顺便说一句,它非常相似。这就是链接
SELECT * FROM post
WHERE title LIKE '%some%'
AND title LIKE '%good%'
SELECT post.post_id, title FROM Post
RIGHT JOIN Tags
ON post.post_id = tags.post_id
WHERE Tags.value IN ('some','good')
GROUP BY post.Post_ID
HAVING COUNT(*)>1;