Home > SQL

MySql Subtract a table from another

16. May 2013

MySql Subtract a table from another

I found this solution on - http://stackoverflow.com/questions/5738240/mysql-subtract-a-table-from-another

To view all rows in A except those in B:

SELECT*FROM A
WHERE(field1, field2,..., fieldN)NOTIN(SELECT*FROM B
);

To actually delete from table A the rows that are in B:

DELETEFROM A
WHERE(field1, field2,..., fieldN)IN(SELECT*FROM B
);

SQL ,

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading