Solved

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

Posted on 2016-09-01
2
34 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 17

Accepted Solution

by:
Pawan Kumar Khowal 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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

706 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now