Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to select where a column contains a column!

Status
Not open for further replies.
May 24, 2002
4
US
Hi,

I can't figure this out. I am trying to select all records from a table(formatted) where one of its columns contains the value of a column in another table(paths). The data in the second table is a substring of the data in the first. Confused yet? Here is one example of what I am trying.

SELECT *
FROM formattted
WHERE CONTAINS (formatted.path, paths.path)

I just can't seem to get the syntax correct.

Thanks!
-Jim
 
Is this what you were looking for?

Code:
SELECT *
FROM formatted join path
on formatted.path = path.path
 
Actually, if you are dealing with substrings, you'll want to do something like the following. If the tables a very large, performance could be a problem.

This may also return unwanted rows because it is not selecting based on an exact match or JOIN criteria. Multiple rows in the Formatted table may match a single row in the paths table.

SELECT *
FROM formattted, paths
WHERE charindex(paths.path, formatted.path)>0 Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top