database - Need help combining two functional mysql querys into one? -



database - Need help combining two functional mysql querys into one? -

i have query homecoming list of of people associated thomas , ids.

select c.name, c.id namesandid s, associations o, namesandid c s.name='thomas' , o.id = s.id , o.associateid = c.id grouping c.id;

then have query can manually type in id number , homecoming right count of associates.

select count(*) ( select associateid associations id=18827 grouping associateid ) t;

my goal have 1 query take thomas name , homecoming 3 columns have associate id number number of people associated with.

also additional info big database 4million rows , 300million associations speed increment on either of these queries welcomed.

not tested, below should work:

select c.name, c.id, assoc_count.cnt namesandids s inner bring together associations o on o.id = s.id inner bring together namesandid c on c.id = o.associateid left outer bring together ( select id, count(distinct associateid) cnt associations grouping id ) assoc_count on assoc_count.id = c.id s.name = 'thomas'

mysql database

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -