Hi all, hope in your help.
I have three tables in MySQL.
1) tbl_L with fields ID and source;
2) tbl_N with fields ID, source and flags;
3) tbl_ip with fields ID and COUNTRY_CODE.
I need count rows in tbl_L grouped by source and associated for single source the field flags (of the tbl_N) and the field COUNTRY_CODE (of the tbl_ip) and I tried this join query;
This output is incorrect because if I tried this simple query count I have the exact numbers, can you help me?Code:mysql> SELECT a.source, CA.source, CB.COUNTRY_CODE2, CB.FLAGS, COUNT(*) FROM tbl_L A JOIN tbl_N CA ON a.source = CA.source JOIN tbl_ip CB ON UCASE(CA.source) = CB.COUNTRY_CODE2 WHERE a.source NOT IN ('1X', '2F', '3T') GROUP BY a.source LIMIT 5; +---------+---------+---------------+--------+----------+ | source | source1 | COUNTRY_CODE2 | FLAGS | COUNT(*) | +---------+---------+---------------+--------+----------+ | AD | AD | AD | AD.PNG | 10 | | AL | AL | AL | AL.PNG | 46 | | AR | AR | AR | AR.PNG | 6435 | | AT | AT | AT | AT.PNG | 6528 | | AU | AU | AU | AU.PNG | 2532 | +---------+---------+---------------+--------+----------+ 5 rows in set
thank you.
Code:mysql> SELECT source, COUNT(*) FROM tbl_L WHERE source NOT IN ('1X', '2F', '3T') GROUP BY source LIMIT 5; +---------+----------+ | source | COUNT(*) | +---------+----------+ | AD | 1 | | AL | 1 | | AR | 11 | | AT | 4 | | AU | 1 | +---------+----------+ 5 rows in set



Reply With Quote






):
Bookmarks