简体   繁体   中英

How to implement search functionality in SQL?

除了SQLQuery,联接和条件查询外,我如何实现搜索功能?

The simpliest way is to use like condition:

select * from Table where fieldName like '%searchword%'

But it's very slow, so it's better to use full-text indexing: in mysql , in sql server

Well, outside of SQL, you're left to the calling application to do searches. Definitely not the recommended choice if you can avoid it as you'll have to read all data first before searching it; indexing is a very powerful feature for databases.

If you want to display all data and then manipulate/sort/filter it, however, this method has its place.

Perhaps you wish to clarify your question as to what you're looking to accomplish?

最好使用sphinxsolr之类的东西来实现一个真正的搜索引擎,而不是使用大多数数据库提供的东西,甚至是mysql的全文本搜索。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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