简体   繁体   中英

how to fix sql query error

I have this request

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

but got

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

Please help, how I can fix it?


UPDATE remove "SUBSTR" to SUBSTR, but get 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:99 - SQL syntax error: the token "(" was not expected here


UPDATE 2

I change to

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

and get - SQL syntax error: the token "," was not expected here - expecting "from", found ','

You do not need Double quotes around SUBSTR. Also you can not use SELECT * . Use count(*)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM