Mysql joins 3 tables and counts

Please look at this image.

alt text

there are 3 tables and I want this

uid from table table 1 from table 3 of the same counting identifier fid from table 2 of the same identifier

as in the example output example there will be 2 entries

thank

+5
source share
2 answers

I do not see any relation to table 1. Here is an example of using an internal join between two tables and grouping using uid:

SELECT 
  t3.uid, 
  t3.industry, 
  count(t2.fid) 
FROM 
  table3 t3 
INNER JOIN 
  table2 t2 ON t3.uid = t2.uid 
GROUP BY 
  t3.uid
+5
source

Try the following:

SELECT table1.uid,table3.industry,COUNT(table2.fid) 
FROM table1 
INNER JOIN table3 ON table1.uid=table3.uid
INNER JOIN table2 ON table1.uid=table2.uid
GROUP BY table1.uid, table3.industry

1 , , mem_no; GROUP BY.

+4

All Articles