Okay so I have three user tables separated intentionally. I have written some PHP to allow any user (Designer/Developer/Employer) to log in using a UNION query however this only works with the Developer and Employer tables. As soon as I add the Designer table to the query, it is impossible to log in. If I use just the Designer table in the query, that also works. Any ideas?
This used to work but now doesn't (Developers, Employers and Designers
$email = clean_string($db_server, $email);
$password = clean_string($db_server, $password);
$query = "SELECT * FROM connectdDB.developers WHERE developers.email='$email' UNION SELECT * FROM connectdDB.employers WHERE employers.email='$email' UNION SELECT * FROM connectdDB.designers WHERE designers.email='$email'";
$result = mysqli_query($db_server, $query);
This works (Developers & Employers)
$email = clean_string($db_server, $email);
$password = clean_string($db_server, $password);
$query = "SELECT * FROM connectdDB.developers WHERE developers.email='$email' UNION SELECT * FROM connectdDB.employers WHERE employers.email='$email'";
$result = mysqli_query($db_server, $query);
This works (Just Designers)
$email = clean_string($db_server, $email);
$password = clean_string($db_server, $password);
$query = "SELECT * FROM connectdDB.designers WHERE designers.email='$email'";
$result = mysqli_query($db_server, $query);
Designers
id | firstname | lastname | email | password | jobtitle | age | experience | bio | speciality
--------------------------------------- ------------------------------------------------------
Developers
id | firstname | lastname | email | password | jobtitle | age | experience | bio |
--------------------------------------- -------------------------------------------
Employers
id | firstname | lastname | email | password | businessname | businesstype | businesswebsite | businessbio |
-------------------------------------------------------------------------------------------------------------
Designers
has 10 columns the others have 9 columns.Union
requires the same number of columns,what you could do is specify the columns
SELECT col1,col2... FROM t1 UNION SELECT col1,col2... FROM t2
Use aliases to homogenize the column names.