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

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -