简体   繁体   中英

Mysql how to get the records from tableA that dont appear in tableB

i need help on how to get the intersection of two tables in mysql

TABLE A Col-a Col-b

TABLE B Col-a Col-b

I need all the values in table B that are not in table AI don't want to use NOT IN because it seems to take over 30 minutes :| Table A has 35000 records Table B has 36128 records (but table b is a VIEW from an inner join) Thanks for helping me.

According to the picture shown here , I'd suggest this right join :

select b.* 
  from table_a a 
 right join table_b b 
    on a.col_a=b.col_a and a.col_b=b.col_b
 where a.col_a is null;

Edit: I updated the statement so that now two columns are used for comparision.

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