简体   繁体   中英

Check value between two tables (MS ACCESS)

I have two table:

table1: colName

values: Ford, Audi, Opel

table2: colNewName

values: 87 Ford Carl, one9 Audi, _12br Opel 45X

How to write query, to check if values from table1 exist into table2?

expect Result :

table1  table2            Result
Ford    "87 Ford Car"     True
Audi    "one9 Audi"       True
Opel    "_12br Opel 45X"  True

A simple select query will do:

SELECT 
    table1.colName, 
    table2.colNewName, 
    table2.colNewName Is Not Null As Result
FROM 
    table1 
LEFT JOIN 
    table2 
    ON table2.colNewName Like "*" & table1.colName & "*"

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