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

One column contained in another

I have a table in which I need to compare two columns. Column A contains a string that should be part of Column...

B. For example, Column A is "Boxer" and Column B is "Dog Breed Boxer". I need to find the rows where the string in Column A is not embedded as part of the string in Column B.

Seems pretty straightforward. Try this:

select A, B
  from yourtable
 where B not like '%' || A || '%'

Note: you may have to substitute your particular database's string concatenation operator for the standard SQL "double pipes" (||) operator.

For More Information


This was last published in December 2003

Dig Deeper on Oracle and SQL

PRO+

Content

Find more PRO+ content and other member only offers, here.

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.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close