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 (M_BERICHT = 1) ORDER BY FoBeFulda_PERSONEN.PS_NAME_SORT' at line 1 - SELECT FoBeFulda_MBER.M_PS_REF,FoBeFulda_MBER.M_MA_REF,FoBeFulda_PERSONEN.* FROM FoBeFulda_MBER LEFT JOIN FoBeFulda_PERSONEN ON FoBeFulda_MBER.M_PS_REF=FoBeFulda_PERSONEN.PS_ID WHERE FoBeFulda_MBER.M_S_REF= AND (M_BERICHT = 1) ORDER BY FoBeFulda_PERSONEN.PS_NAME_SORT;