I have a database where there are 6 different tables (Alpha, Beta, Gamma, Theta, Epsilon, Pi) and there is a users table where one user can be in a different role inside the tables. He can be director of Alpha and Faculty in Beta.
the column names are different in each table(Director, Faculty, Member, Advisor, Student etc)
I need a mysql query which will check if a particular is present in one or more tables against his role.
Thank You.
Without a table structure, it is difficult to give answers. But assuming you have a user master table and different role based tables you can do the following
select user.id, a.director, b.faculty, c.member, d.advisor, e.student, f.user from user
left join alpha a on user.id = a.director
left join beta b on user.id = b.faculty
left join gama c on user.id = c.member
left join ththa d on user.id = d.advisor
left join epsilon e on user.id = e.student
left join pi f on user.id = f.user
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments