I have a table in mysql base, where are the records of all the teams (it is for a soccer page) I need to pair it with two tables but only counting some values. For example:
Base table called "computers", where the other data will be taken
id equipo
(int) (varchar)
-------------------
afc Aragua
ccs Caracas
dan Anzoátegui
This table is what I want to match called "data".
id equipo1 equipo2 data3
(int) (varchar) (varchar) (int)
-------------------------------------
1 dan ccs 456
2 ccs dan 654
3 ccs dan 666
Then I have dealt with:
SELECT eq.id, eq.equipo, count(dat1) AS dato1, count(dat2) AS dato2
FROM equipos AS eq
INNER JOIN datos AS dat1 ON dat1.equipo1 = eq.id
INNER JOIN datos AS dat2 ON dat2.equipo2 = eq.id
GROUP BY eq.id
ORDER BY eq.equipo ASC
I know it does not work like that, but I would like to see something like this:
equipo dato1 dato2
-------------------------------
dan 1 2
ccs 2 1
afc 0 0
The problem I have is that the afc value does not appear is NULL in the database "data" then it does not appear in the search.