MYSQL匹配查询两个表

编程入门 行业动态 更新时间:2024-10-27 05:21:30
本文介绍了MYSQL匹配查询两个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否可以使用联接对具有两个表的查询进行匹配?棘手的部分可能是表上的索引,但也许有一种方法.sql不是我的强项.非常感谢.我想可能是这样的:

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')

非常感谢

推荐答案

可能,但是您需要文本索引.

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')

我想这足以工作.

从MySQL 5.6开始,上述全文搜索可以在MyISAM& InnoDB存储引擎.在早期的MySQL版本上,只有MyISAM表支持全文索引.

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.

dev.mysql/doc/refman/5.6/en/fulltext-search.html

更多推荐

MYSQL匹配查询两个表

本文发布于:2023-10-20 08:56:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1510509.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两个   MYSQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!