Click here to Skip to main content
15,914,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
please how do i retrieve records from two tables, Table_A and Table_B, where data in column(colWord) of Table_B is a substring of data in column(colC) of Table_A? ie. SQL server

Eg.

Table A
id|colC
--------
1 |tomorrow is wednesday
2 |I will be there
3 |this is an example


Table_B
id | colWord
--------------
1 |wednesday
2 |there
3 |example
4 |come

using
SQL
select colC,colWord ....
statement should return

colC | colWord
-----------------------------------------------
tomorrow is wednesday |wednesday
I will be there |there
this is an example |example

What I have tried:

The filter to use is my problem
Posted
Updated 10-Jul-17 3:59am
Comments
Wendelius 10-Jul-17 11:42am    
What should happen if the sentence contains two or more of the words?

1 solution

if the data is small enough then just use a like comparison in the join:

SQL
Select * from Table_A a
inner join Table_B b on a.colC like '%'+b.colWord+'%'


This will be terrible for large data!

If you need a query for large data there are solutions
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900