Question : Delete where record is NULL

OK so let's say I have two database tables.

table: table_one
table: table_two

table one has the following fields
id, message, page
table_two has the following fields
id, sitelink, text

Now let's say table one has this in its record:
1:
2:
3:
1, Testing, 4 // ID, message, page
2, EE!!, 5 // ID, message, page
4, Cool, 4 // ID, message, page


table two has this in its record
1:
2:
3:
4:
1, http://google.com, Google // id, url, text
2, http://ask.com, ask // id, url, text
3, http://microsoft.com, microsoft  // id, url, text
4, http://facebook.com, facebook  // id, url, text


The data inside these tables is irellevant actually... just focus on the IDs of each table.

I want to make a script that runs and let's say... it goes through table one and list all the IDs into an Array (doesn't have to be an array - but just do whats needed)
then it goes through table 2 and if the ID is  NOT there... then delete it!

So, in this instance, since it found the record with the ID of 3 inside table two but NOT in table 1... then it would delete it it from table two... get what i am saying?

here is what I have so far:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
<?php

// DATABASE CONNECTION
$conn = mysql_connect("localhost","root",""); 
mysql_select_db("my_database") or die(mysql_error()); 

$doexe = mysql_query("SELECT * FROM `table_one` ORDER BY `id`");

while ($do = mysql_fetch_array($doexe)) {
    
    echo "$do[id] - $do[fname] - $do[lname]<br />";
    
    $findemail = mysql_query("SELECT * FROM `table_two` WHERE `id` = NULL ORDER BY `id`");
while ($a = mysql_fetch_array($findemail)) {
  
  echo "ID found in table_two but not found in table_one -- Time to delete: $a[id] <br />";
  
  }
    
}

?>


Thanks.

Answer : Delete where record is NULL

"Nope - didn't work. :( Maybe I have the tables the other way around? Switch the database tables in the mysql queries?"

Sorry, I misread the question, I thought the problem was with the  NULL.
Random Solutions  
 
programming4us programming4us