Sql (partial) search in a list and get matched fields

Posted by qods on Stack Overflow See other posts from Stack Overflow or by qods
Published on 2010-06-10T16:30:02Z Indexed on 2010/06/10 16:32 UTC
Read the original article Hit count: 184

Filed under:
|
|
|
|

I have two tables, I want to search TermID in Table-A through TermID in Table-B and If there is a termID like in Table-A and then want to get result table as shown below.
TermIDs are in different length. There is no search pattern to search with "like %"
TermIDs in Table-A are part of the TermIDs in Table-B
Regards,

Table-A

ID         TermID
101256666 126006230
101256586 126006231
101256810 126006233
101256841 126006238
101256818 126006239
101256734 1190226408
101256809 1190226409
101256585 1200096999
101256724 1200096997
101256748 1200097005

Table-B

TermNo TermID
14 8990010901190226366F
16 8990010901190226374F
15 8990010901190226382F
18 8990010901190226408F
19 8990010901190226416F
11 8990010901200096981F
10 8990010901200096999F
12 8990010901200097005F
13 8990010901200097013F
17 8990010901260062337F

As a result I want to get this table;
Result Table -TableA.ID TableA.TermID TableB.TermNo

A.ID      A.TermID  B.TermNo
101256734 1190226408 18
101256585 1200096999 10
101256748 1200097005 12

© Stack Overflow or respective owner

Related posts about sql

Related posts about search