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.
我正试着让一些学生从我们的moodle中匿名。我正在使用mysql skript。得到误差。谁能帮我解决这个问题吗?
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;`;
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
如果[$(ANZ)) -gt 0]那么mysql -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "选择id,从$TABLE中删除=1而不是lastname='anonym'和用户名'%@%';"美元——skip-column-names - b >文件;cat $FILE |,读取TMP
do
做
UserID=${TMP% *};
echo $UserID >> $RES_FILE;
echo "User $UserID wird anonymisiert...";
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;"
;
mysql和useru $USER -p$PASSWD -h$HOST -D $DATABASE -e "UPDATE $ SET username='$A$UserID', email='a@nonym.de', firstname='$A', lastname='$A', icq= ", skype= ", yahoo= ", aim= "
`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!";
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
我有以下错误:第1行错误1064 (42000):SQL语法有错误;检查与MariaDB服务器版本对应的手册,找到在第1行使用“near”和“deleted =1”和“id=715”的正确语法
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.
第1行错误1064 (42000):SQL语法中有错误;检查与MariaDB服务器版本对应的手册,找到在第1行使用“near”和“deleted =1”和“id=3478”的正确语法。
please help me.i am new in SQL.
请帮助我。我是SQL新手。
many thanks for your help.
非常感谢你的帮助。
1 个解决方案
#1
1
You have
你有
WHERE AND deleted =1 AND id=$UserID;
It should be:
应该是:
WHERE deleted =1 AND id=$UserID;
Without AND
between WHERE
and deleted
没有,在哪里和删除之间
#1
1
You have
你有
WHERE AND deleted =1 AND id=$UserID;
It should be:
应该是:
WHERE deleted =1 AND id=$UserID;
Without AND
between WHERE
and deleted
没有,在哪里和删除之间