How to check the existence of two columns' data in two different tables ? MySQL

前端 未结 2 1148
轻奢々
轻奢々 2021-01-17 06:54

I have two different tables in two different databases ..

what I want to do is to check if the data of two columns exist in the other table .. if it does exist count

2条回答
  •  一向
    一向 (楼主)
    2021-01-17 07:12

    Do an INNER JOIN on both tables:

    SELECT COUNT(*)
    FROM table_1 t1
    INNER JOIN table_2 t2
        ON t1.column_1 = t2.column_1
        AND t1.column_2 = t2.column_2
    

提交回复
热议问题