1. 程式人生 > >your MySQL server version for the right syntax to use near 'NULL' at line 1

your MySQL server version for the right syntax to use near 'NULL' at line 1

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 ‘NULL’ at line 1

    今天使用mysql事件執行一段程式,  
    set @deletesql =CONCAT('DELETE from classuserorder',' where a=',a);
    PREPARE stmt FROM @deletesql;
    EXECUTE stmt 
; DEALLOCATE PREPARE stmt; 老是報異常,看錯誤應該是sql中有null,應該是concat拼接null後結果@deletesql為null,導致報錯,對引數a做下判斷即可