我是靠谱客的博主 哭泣方盒,最近开发中收集的这篇文章主要介绍mysql+两个表匹配,MYSQL匹配查询两个表,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Is it possible to do a match against a query with two tables using a join? The tricky part might be the index on the table but maybe there is a way.. sql is not my strong suit. Many thanks. I imagine it might be something like the following:

SELECT * FROM 'pages' p

LEFT JOIN `tags` t

ON p.id = u.pageid

WHERE MATCH(p.shdescript,t.tag) AGAINST ('romance, relationship')

Many thanks

解决方案

It's possible, but you need to have text indexes.

mysql> alter table pages add fulltext index_text(shdescript);

mysql> alter table tags add fulltext index_text(tag);

SELECT * FROM 'pages' p

LEFT JOIN `tags` t

ON p.id = u.pageid

WHERE MATCH(p.shdescript,t.tag) AGAINST ('romance relationship')

I guess that's enough to work.

EDIT:

As of MySQL 5.6 the above fulltext search can be done on the MyISAM & InnoDB storage engines. On earlier MySQL versions only MyISAM tables supported fulltext indexes.

最后

以上就是哭泣方盒为你收集整理的mysql+两个表匹配,MYSQL匹配查询两个表的全部内容,希望文章能够帮你解决mysql+两个表匹配,MYSQL匹配查询两个表所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(39)

评论列表共有 0 条评论

立即
投稿
返回
顶部