#1242 error my sql

2018-10-21 22:50:26

I'm writing a query and msql return me #1242 error;

here is the query, everything works fine but the issue comes from the subquery as it always give the same result instead of adapting this result depending on the usager.id

if I remove the Where clause the error appears

do you have any ideas how to fix that query ?

thank a lot

SELECT usager.nom,usager.prenom,usager.pseudonyme, usager.banni,COUNT( sujets.idCreateur) AS 'nb_sujets',usager.id,

(SELECT COUNT( reponses.idUsager)

FROM usager

Left Join reponses ON reponses.idUsager = usager.id

WHERE reponses.idUsager = usager.id

GROUP by usager.id) as 'nb_reponses'

FROM usager

LEFT Join sujets ON sujets.idCreateur = usager.id

GROUP by usager.id