简体   繁体   中英

How use inner join using 2 variable field?

I have 2 tables ABC and XYZ I want to inner join the with name field.

ABC table

     Name     Address     Phone
   Nirdosh    Kth         96749343
   Hari       pokhara     98493434

XYZ table

    Name      Address   Phone
   Shrestha    Daldale  96749343
    Hari       pokhara     98493434

I use INNER JOIN

select actual.*,more.* 
from ABC actual 
INNER JOIN Xyz more 
ON like %'actual.Name'% = like %'more.Name'%  

Are you saying more.Name is more or like actual.Name, but need not be exactly the same as actual.Name?

select actual.*, more.*
from ABC actual 
inner join XYZ more on more.Name like concat('%', trim(actual.Name), '%')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM