I have 2 tables:
- customer
- customer_communication
the customer table has a unique sequence
column and the customer_communication table has customer_seq
which matches the sequence column in the customer table.
The rows in the customer_communication table have a datetime column, i am selecting data from both tables using these queries:
echo '<table width="100%" border="0" cellspacing="10" cellpadding="10">';
//select from the customer_communication table
$sql="SELECT * from customer where company_status = '' and no_communication = '' order by company ASC ";
$rs=mysql_query($sql,$conn);
while($result=mysql_fetch_array($rs))
{
$sql2="SELECT * from customer_communication WHERE customer_seq = '".$result["sequence"]."' and datetime > DATE_ADD(DATE(now()), INTERVAL 15 DAY) order by datetime ASC ";
$rs2=mysql_query($sql2,$conn);
if(mysql_num_rows($rs2) > 0)
{
echo '<tr>
<td><a href="customer_communication.php?seq='.$result["sequence"].'">'.$result["company"].'</a></td>
</tr>';
}
}
echo '</table>';
so it selects all the rows from the customer table, then selects the rows from the customer_communication table where the customer_seq = sequence and its been 15 days from the datetime column.
how can i show all the rows from the customer table that do not exist in the customer_communication table
for example, there is sequence 1 in customer and this does not exist in the customer_seq column in the customer_communication table so i want to show this