Solved

Serch for terms within SQL table that exist in a second table

Posted on 2016-09-01
2
49 Views
Last Modified: 2016-09-12
I have a table of text terms that I want to search a second table to see if any of the Text Terms in the first table exist in a description in the second table excluding itself.

For clarity purposes I have attached an excel spreadsheet that shows an example of what I'm looking for.

The first column of data is in table # 1 (tmpTextIDTable) and contains a single column of text entries labeled TextID.
Columns E and F reference table #2 (tmpTextMatchDetails) which contain two columns TextID and TextDescription.

TextId is the key field to join the two tables.

You will not that the rows marked with either yellow or green, contain a reference to one or more references to the TextID text from table 1, however references to its own TextID is excluded.

I essentially want to create a list that tells me which rows from table two have a reference to any of the textid excluding itself.

Does this make sense?

Thanks for any direction you have
TextMatch.xlsx
0
Comment
Question by:jdr0606
2 Comments
 
LVL 28

Accepted Solution

by:
Pawan Kumar earned 500 total points
ID: 41780907
Use below approach..

Solution 1

---------------------------------------

SELECT Words.Texts Word , r.Texts Texts
FROM Words
CROSS APPLY
(
    SELECT Texts FROM Texts
)r
WHERE CHARINDEX(Words.Texts,r.Texts,0) > 0

SOLUTION 2

-------------------------------------

SELECT Words.Texts Word , r.Texts Texts
FROM Words
CROSS JOIN Texts r
WHERE CHARINDEX(Words.Texts,r.Texts,0) > 0


URL for ref --
https://msbiskills.com/2016/07/06/sql-puzzle-word-search-puzzle/


Enjoy ! Let me know in case you want me to write the exact query.. for that you need to share your table design for both the tables.
0
 

Author Comment

by:jdr0606
ID: 41794121
That gave what I needed to make it work

Thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
t-sql Joining Issue 10 40
Need some help to cast ntext to nvarchar SQL 2000 7 33
Query Help - MSSQL - Averages 5 27
VB.NET 2008 - SQL Timeout 9 24
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question