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

One column LIKE another column

Can one ask for the content of a field in a like condition?

Can one ask for the content of a field in a like condition? As in the SQL statement:

select * from table1 as a, table2 as b 
where a.field1 like '%b.field2%'

Yes.

select a.foo
     , a.bar
     , a.field1
     , b.qux
     , b.fap
     , b.field2
  from table1 as a
inner
  join table2 as b 
    on a.field1 like '%' || b.field2 || '%'

Please don't use the dreaded, evil "select star." Please always try to write your joins using JOIN syntax, not the older style which lists tables using commas.

Are you surprised to see something other than an equals sign in the ON clause? Joins condition can actually be written with all kinds of comparison operators.

This was last published in January 2007

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.com

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close