troubleshooting Question

Check if an entered email address exists in 2 tables

Avatar of peps03
peps03 asked on
DatabasesPHPMySQL Server
5 Comments1 Solution778 ViewsLast Modified:
Hi,

I have two tables, students and companies which both have a column named email. I need to check if an entered emailaddress exists in the tables.

I tried this:

$query = "select
      NOT EXISTS (select email from students where email = '$email[2]') AND
      NOT EXISTS (select email from companies where email = '$email[2]')";

      $result = mysql_query($query) or die(mysql_error());
      if (mysql_num_rows($result))

But this always returns that the email address already exists.

How should i preform this check correctly?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros