简体   繁体   English

如何在MySQL的一个表的一列上进行搜索调用?

[英]How do I do a search call on one column of a table in MySQL?

I'd like to make a call on MySQL where I have a very big table. 我想在MySQL上打电话,我有一张非常大的桌子。 I'd like query to be able to search in one of there columns and find similar results. 我想查询能够在其中一个列中搜索并找到类似的结果。 This is the sql query I have been trying: 这是我一直在尝试的SQL查询:

SELECT gene FROM promoter where gene LIKE '%ccl5%' limit 10;

I included "limit 10" just to try it out. 我加入了“限制10”只是为了尝试一下。 I have indexing on "gene" and it takes over 5-6 seconds for it to make this search. 我对“基因”进行索引,它进行搜索需要5-6秒。 How can I search for a "phrase" in a specific coloumn with a least a decent speed? 如何在速度最低的特定coloumn中搜索“短语”?

I would also like to only get one of each result returned. 我还希望只返回每个结果中的一个。 If I search for 'ccl5' and it has been found several times, I get a list with all of 'ccl5' returned. 如果我搜索'ccl5'并且已经多次找到它,我会得到一个包含所有'ccl5'的列表。 I have tried using SELECT DISTINCT, but this causes the server to process the query for a long time.. I have yet to see it finish with this command. 我尝试过使用SELECT DISTINCT,但这会导致服务器长时间处理查询。我还没有看到它完成此命令。

If your values are really that big, you can try an InnoDB fulltext index : 如果您的值非常大,可以尝试使用InnoDB全文索引

ALTER TABLE promoter add fulltext index index_name(gene);

Then select it like this: 然后选择它:

SELECT gene FROM promoter WHERE match (gene ) against ('ccl5');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM