如何修复sql查询错误

时间:2015-08-19 12:54:58

标签: mysql sql

我有这个要求

 DELETE FROM T1 WHERE PERMISSION_ID = 'x' AND 
 0<(SELECT * FROM T2 WHERE "SUBSTR"(PID,1,1)=1)  OR '1'='1'

但得到了

The SQL statement " DELETE FROM T1 WHERE PERMISSION_ID = 'x' 
AND 0<(SELECT * FROM T2 WHERE SUBSTR(PID,1,1)=1)  OR '1'='1'" 
contains the syntax error[s]: - 1:101 - SQL syntax error: the token 
"(" was not expected here

请帮忙,我该如何解决?

UPDATE 删除“SUBSTR”到SUBSTR,但获取SQL语句

DELETE FROM T1 
WHERE PERMISSION_ID = 'x' 
AND 0= (SELECT * FROM T2 WHERE SUBSTR(PID,1,1)=1)  OR '1'='1'

包含语法错误[s]: - 1:99 - SQL语法错误:令牌“(”这里不是

更新2

我改为

SELECT count(*) FROM T2 WHERE SUBSTRING("asdqweasd",1,1))

得到   - SQL语法错误:此处不会出现令牌“,”   - 期待“来自”,找到','

1 个答案:

答案 0 :(得分:0)

SUBSTR周围不需要双引号。你也不能使用SELECT *。使用count(*)

html = """<form id="dialog_confirm" title="#{message}" enctype="multipart/form-data"><ul>"""