我有2个表首先是
之前
lotname
--------
R16A
R17A
R17B
R18A
R18B
第二是
之后
lotname
--------
R16AA
R17A
R17B
R18AAA
R18B
我想加入这两个表,以便像R16A
匹配的所有内容都应与R16AA
匹配
如果我写这段代码
select * from before
join after
on before.lotname = after.lotname
O / P
lotname lotname
R17A R17A
R17B R17B
R18B R18B
我想要o / p喜欢
Lotname Lotname
----------------------------
R16A R16AA
R17A R17A
R17B R17B
R18A R18AAA
R18B R18B
答案 0 :(得分:5)
SELECT *
FROM before
INNER JOIN after
ON after.lotname LIKE before.lotname + '%'
答案 1 :(得分:0)
[ re.sub(r'(' + '|'.join(list_1) + ')\d+', r'\1', string) for string in list_2 ]
答案 2 :(得分:0)
SELECT * FROM before
INNER JOIN after
ON after.lotname LIKE CONCAT(before.lotname,'%')