0

I have table A and table B and they are both joined through a relationship. table B has a foreign key of table A's key. Table A is joined when the program runs because it is dynamic and could reside in any database. How would I find all the rows in table B that are no longer found in table A?

For ex.
Starting out we have
table A     table B
4              4
3              3
5              5

later that evening

table A deleted some rows

table A        table B
NULL              4
3                 3
NULL              5

I want to get the keys 4,5 so that I can tell what was deleted.

thedr
  • 70
  • 3
  • tip: use real names, real examples - ask about real problems. And as far as php logic goes - you need to know/understand the sql query you need. If you are not sure, you're asking the wrong question :). – AD7six Jul 30 '13 at 18:07
  • this is a real example – thedr Jul 30 '13 at 18:35
  • you have a table named a and a table named b each with one field? I don't believe you - sorry. – AD7six Jul 30 '13 at 18:51

1 Answers1

0

Just use mysql where not in table. I would just use cakephp query method versus find. Here is a topic that already has been answered: Where not in table

Community
  • 1
  • 1
Sixthpoint
  • 1,161
  • 3
  • 11
  • 34