我有2张桌子:
表1
Name Address Phone
Nirdosh Kth 96749343
Hari pokhara 98493434
表2
Name Address Phone
Shrestha Daldale 96749343
Hari pokhara 98493434
我想在Name字段中加入,其类型为字符串:
select Table1.*,Table2.*
from Table1 actual
INNER JOIN Table2 more
ON LIKE ('actual.Name') = LIKE('more.Name')
但我收到了错误。
答案 0 :(得分:1)
您使用like
运算符是错误的。您可以使用=
运算符来比较字符串:
SELECT Table1.*,Table2.*
FROM Table1 actual
INNER JOIN Table2 more ON actual.Name = more.Name
答案 1 :(得分:1)
如果您认为Table2 Name,即more.name不一定与actual.name完全相同,您可以使用以下
select actual.*, more.*
from Table1 actual
inner join Table2 more on more.Name like concat('%', trim(actual.Name), '%')