I'm having a problem whith a mysql funcion in PHP. here's an example or the data:
table_1 table_2
ID_field ID_field
1 1
2
3 3
4
5 5
6
7 7
8
9
10 10
What I want it it do to is select the data ID_field in table_1 that doesn't exist in table_2. The results for this example should be 2, 8 and 9
Here is my code that doesn't work.
$table1select = "select 1.ID_field
from table1 as 1, table2 as 2
where 1.ID_field != 2.ID_field";
if ($result = mysql_query ($table1select) ) {
while ($row = mysql_fetch_array($result) ) {
echo "Unique ID: ".$row[ID_field]."<br>\n";
}
} else {
echo "there is a problem";
}
Any suggestions???
table_1 table_2
ID_field ID_field
1 1
2
3 3
4
5 5
6
7 7
8
9
10 10
What I want it it do to is select the data ID_field in table_1 that doesn't exist in table_2. The results for this example should be 2, 8 and 9
Here is my code that doesn't work.
$table1select = "select 1.ID_field
from table1 as 1, table2 as 2
where 1.ID_field != 2.ID_field";
if ($result = mysql_query ($table1select) ) {
while ($row = mysql_fetch_array($result) ) {
echo "Unique ID: ".$row[ID_field]."<br>\n";
}
} else {
echo "there is a problem";
}
Any suggestions???