I want to check if the given username exists in at least one of the two given tables and if it is exists then it will shows them a message that the username already exists. I wrote some code using the UNION statement but it does not show me the message. Can you tell me please what is wrong with my code? Thanks
if (mysql_num_rows(queryMysql("SELECT * FROM doctor
WHERE username='$username' UNION SELECT * FROM patient
WHERE username='$username'")))
$error = "That username already exists<br /><br />";
else
{
queryMysql("INSERT INTO doctor (fname,lname,username,email,password,gender,age,specialty,doctorID) VALUES('$fname','$lname','$username','$email', '$password','$DoctorG','$DoctorAge','$specialty','$Doctor_ID')");
die("<h4>Account created</h4>Please Log in.<br /><br />");
}