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
- Dozens more answers to tough SQL questions from Rudy Limeback.
- The Best SQL Web Links: tips, tutorials, scripts, and more.
- Have an SQL tip to offer your fellow DBAs 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, SQL Server, DB2, object-oriented 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.