database - How to join multiple tables in MySQL 3? -


i want see citizen's full name emails

where notifyemployee ='1' in reportbasket,reportnobasket tables

and count email reportbasket, citizenemail reportnobasket in 1 counter

tables:

citizen(email, firstname,lastname)

reportbasket(email,notifyemployee)

reportnobasket(citizenemail, notifyemployee , groupemail)

before use query

select concat(firstname, ' ', lastname), count(*) citizen_count  ( select c.firstname, c.lastname reportbasket rb join citizen c     on rb.email = c.email notifyemployee='1' union  select c.firstname, c.lastname reportnobasket rnb join citizen c     on rnb.citizenemail = c.email notifyemployee='1' ) t group firstname, lastname order firstname, lastname asc  

select concat(firstname, ' ', lastname) fullname, count(*) email_count     , email email ( select c.firstname, c.lastname,c.email reportbasket rb join citizen c     on rb.email = c.email notifyemployee='1' union  select c.firstname, c.lastname, c.email reportnobasket rnb join citizen c     on rnb.citizenemail = c.email notifyemployee='1' ) t group firstname, lastname order firstname, lastname asc ; 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -