title: ERROR 1064 (42000) at line 1: You have an error in your SQL syntax;
body: <p>i am trying to anonymize some student form our moodle.i am using mysql skript.
  and I get the error . Can someone kindly help me resolve this issue.</p>
  
  <pre><code>ANZ=`mysql -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "SELECT count(id) FROM $TABLE WHERE deleted=1 and not lastname='anonym';" --skip-column-names -B;`;
  </code></pre>
  
  <p>if [ $((ANZ)) -gt 0 ]
    then
      mysql -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "SELECT id, username FROM $TABLE WHERE deleted=1 and not lastname='anonym' and username like '%@%';" --skip-column-names -B > $FILE;
      cat $FILE | while read TMP</p>
  
  <p>do</p>
  
  <pre><code>    UserID=${TMP%   *};
  echo $UserID &gt;&gt; $RES_FILE;
  echo "User $UserID wird anonymisiert...";
  </code></pre>
  
  <p><code>mysql -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "UPDATE $TABLE SET username='$A$UserID', email='a@nonym.de', firstname='$A', lastname='$A', icq='', skype='', yahoo='', aim='', msn='', phone1='', phone2='', institution='', department='', address='', city='', country='', url='', WHERE AND deleted =1 AND id=$UserID;"</code>;</p>
  
  <pre><code>    `mysql -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "UPDATE mdl_message SET subject='Neue Mitteilung von anonym' WHERE useridfrom=$UserID;"`;
      `mysql -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "UPDATE mdl_message_read SET subject='Neue Mitteilung von anonym' WHERE useridfrom=$UserID;"`;
  
      VNAME=`mysql -N -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "SELECT firstname FROM $TABLE WHERE id=$UserID;"`;
      NNAME=`mysql -N -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "SELECT lastname FROM $TABLE WHERE id=$UserID;"`;
  
       `mysql -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "UPDATE mdl_event SET name='Meeting with your Student, anonym' WHERE name LIKE 'Meeting with your Student,%$VNAME $NNAME%';"`;
  done
  echo "Fertig!";
  </code></pre>
  
  <p>i have got this errors:
  ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND deleted =1 AND id=715' at line 1</p>
  
  <p>ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND deleted =1 AND id=3478' at line 1.</p>
  
  <p>please help me.i am new in SQL.</p>
  
  <p>many thanks for your help.</p>