i am connecting access to a mysql db.
i need to put together two statements and make them into one.
for example:
SELECT
users.id,
users.first,
users.last,
chavrusas.luser_type AS user_type,
chavrusas.id,
users.title,
users.city,
users.state,
users.home_phone,
users.email
FROM users
INNER JOIN chavrusas
ON Users.id=chavrusas.luser_id
WHERE ((chavrusas.ruser_id)='3166' and chavrusas.ended=false)
AND (chavrusas.luser_type) <> (chavrusas.ruser_type)
AND NOT ((chavrusas.luser_type)='teacher' AND (chavrusas.ruser_type)='student')
AND NOT ((chavrusas.ruser_type)='teacher' AND (chavrusas.luser_type)='student');
UNION
SELECT
users.id,
users.first,
users.last,
chavrusas.ruser_type AS user_type,
chavrusas.id,
users.title,
users.city,
users.state,
users.home_phone,
users.email
FROM users
INNER JOIN chavrusas
ON Users.id=chavrusas.ruser_id
WHERE ((chavrusas.luser_id)='3166' and chavrusas.ended=false)
AND (chavrusas.luser_type) <> (chavrusas.ruser_type)
AND NOT ((chavrusas.luser_type)='teacher' AND (chavrusas.ruser_type)='student')
AND NOT ((chavrusas.ruser_type)='teacher' AND (chavrusas.luser_type)='student')
ORDER BY 4;
Users is a query which is:
SELECT
tblusers.*,
tblusershliach.*,
tbluserstudent.*,
tbluserstudentteacher.*,
tbluserteacher.*
FROM
(
(
(tblusers
LEFT JOIN tblusershliach
ON tblusers.id = tblusershliach.shliach_user_id
)
LEFT JOIN tbluserstudent
ON tblusers.id = tbluserstudent.student_user_id
)
LEFT JOIN tbluserstudentteacher
ON tblusers.id = tbluserstudentteacher.student_teacher_user_id
)
LEFT JOIN tbluserteacher
ON tblusers.id = tbluserteacher.teacher_user_id;
instead of using "Users" in the first statement, i just want to put them together into one statement
how do i do it?