You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND (IDA1= OR IDA1D=)' at line 1---->SELECT DISTINCT A6ID,A1PSEUDO, A1PHOTO,A1ID,A1VILL,A1DATN,A1DPT,IDB1,A1PRES,A1CLUB_NOM,A1CLUB_DESC FROM 502_ba6,502_ba1 WHERE (IDA1=A1ID OR IDA1D=A1ID) AND A6DATC IS NOT NULL AND (IDA1!=IDA1D) AND (A1ID!=) AND (IDA1= OR IDA1D=)