开发者

How to implement search functionality in SQL?

开发者 https://www.devze.com 2022-12-12 21:28 出处:网络
How can I implement search functio开发者_JAVA百科nality other than SQLQuery, Joins and conditional querys?The simpliest way is to use like condition:

How can I implement search functio开发者_JAVA百科nality other than SQLQuery, Joins and conditional querys?


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?


It's better to use something like sphinx or solr to implement a real search engine rather than using things that most databases provide, even mysql's full-text search.

0

精彩评论

暂无评论...
验证码 换一张
取 消