Start Free Trial
Come for the solution, stay for everything else.
Start Free Trial
Check if an entered email address exists in 2 tables
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') AND
NOT EXISTS (select email from companies where email = '$email')";
$result = mysql_query($query) or die(mysql_error());
But this always returns that the email address already exists.
How should i preform this check correctly?
8/22/2022 - Mon
What are you trying to do?
If the email addy exists in neither table, then your SQL statement returns true. If it exists in at least one of the tables, it returns false.
that is what i am trying. but it always returns false
ASKER CERTIFIED SOLUTION
Log in or sign up to see answer
Become an EE member today
7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Simple solution, thought there would be some brilliant solution to stuff it into 1 query, but lets unnecessary not complicate thing too much!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
@peps03: thanks for the points. In my experience, the quest for "brilliant solutions" sometimes complicates my life. So instead I seek solutions that are lazy, pedestrian, simple-stupid and ordinary. It has been a quest that has repeatedly struck gold, giving me the fastest, most accurate answers. Thud! I don't get points at EE by being smarter than anyone else; I get points by plodding along well-traveled paths toward well-defined goals.
All my best, ~Ray
Plans and Pricing
Certified Expert Program
© 1996-2022 Experts Exchange, LLC. All rights reserved. Covered by US Patent