Q
Problem solve Get help with specific problems with your technologies, process and projects.

Using LIKE to return related keywords

I have a column in my database that contains keywords. I want to write a query that returns results that resemble the keyword. For example, if I am serching for AS-400 it should return all the columns containing AS/400, As 400, AS%400 and all related words. I hope it is something related to the indexes but I am not sure. I will highly appreciate if you can guide me regarding that.

Unfortunately, I know of no easy way in SQL to do this. Perhaps certain database vendors have provided extensions to make this easier. The closest thing to a solution I can give you is the LIKE predicate. Your example could be handled like this, but I don't think it's the generic answer for which you're looking:

SELECT * 
  FROM YourTable 
  WHERE UPPER(StringToBeSearched) LIKE ?%AS%400%?

For More Information

  • What do you think about this answer? E-mail the Edtior at tdichiara@techtarget.com with your feedback.
  • The Best SQL Web Links: tips, tutorials, scripts, and more.
  • Have a SQL tip to offer your fellow DBA's and developers? The best tips submitted will receive a cool prize--submit your tip today!
  • Ask your technical SQL questions--or help out your peers by answering them--in our live discussion forums.
  • Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, and data warehousing gurus are waiting to answer your toughest questions.

Dig Deeper on Oracle and SQL

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close