Why MySQL doesn't use my primary key to join my table?

28 views Asked by At

I try to do a SELECT but I don't know why MySQL doesn't join my table with INNER JOIN on the primary key. He uses my foreign key instead...

My query :

SELECT cpte.* 
FROM tcomptes cpte
INNER JOIN tentreprises_acteurs tentGest ON tentGest.nEntrepriseActeur = cpte.nGestionnaire
INNER JOIN tsites s on s.nSite = cpte.nSite

The problem is on the INNER JOIN of the table tsites. There is the result of EXPLAIN instruction below :

result of EXPLAIN

Key uses by tsites table is a foreign key

Can you help me please ?

0

There are 0 answers