H
H
heavybrain2019-10-28 10:29:33
Transact SQL
heavybrain, 2019-10-28 10:29:33

How to make join on like?

There are 2 tables, one has an ID column with the code 576000, the other table also has an ID with the code as in the screenshot, the central part is completely identical, is it possible to make a join? or not? How then to connect according to this criterion?
according to this criterion
5db69f483c3b5695048684.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Konstantin Tsvetkov, 2019-10-28
@heavybrain

SELECT Table_A.ID1, Table_B.ID2
  FROM Table_A INNER JOIN Table_B ON CHARINDEX(Table_A.ID1, Table_B.ID2) > 0

If you need a template, use PATINDEX.

A
Adamos, 2019-10-28
@Adamos

is it possible to do a join?

Can. JOIN ON LIKE is a perfectly valid construct. Brake only.

A
Andrey Skorzhinsky, 2019-10-28
@AndyKorg

Too vague TK. The simplest like '%576000%'
You can also use wildcards

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question