Precious Pari Precious Pari - 9 months ago 50
MySQL Question

database query for single login form extracting data from two signup tables

There are two signup tables one for hire and one for work pictures of the both tables are given below:

Table 1:
table 1

Table 2
table 2

but i want to create single login form for both hire and work user
now i wrote this query for extracting data from both tables,

$sql = " SELECT *
FROM signup_hire
LEFT OUTER JOIN signup_work ON =


FROM signup_hire
RIGHT OUTER JOIN signup_work ON =
WHERE = '$myusername' and signup_hire.password = '$mypassword'
OR = '$myusername' and signup_work.password = '$mypassword'";

but I am receiving 'invalid email or password' - what is the correct query to use?

Answer Source

Have you tried a simple UNION? Query the first table and add a UNION with the same result on the second table, this will will return the results if it matches one of the tables, keep in mind that column names will the ones on the first table regardless which one matches. Also, be sure both tables have the same number of columns or list the fields you need instead of *

SELECT id,name,email
FROM signup_hire
WHERE = '$myusername'
  AND signup_hire.password = '$mypassword'
SELECT id,name,email
FROM signup_work
WHERE = '$myusername'
  AND signup_work.password = '$mypassword';