I'm selecting data from a table called "contacts" to grab email addresses. It's working just fine but I don't want to echo out any results if the email exists in another table called "scheduled_emails". Both tables have a column called "email", so I was thinking I could some how check some kinda comparison. I've been looking into the JOIN to combine rows. Am I wrong?
My script
$sql = "SELECT email FROM contacts WHERE username = '".$_SESSION["username"]."' ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output emails of users account
while($row = $result->fetch_assoc()) {
echo $row["email"];
}
} else {
echo "0 results";
}
Any help would be greatly appreciated :)