简体   繁体   中英

sqlite3.OperationalError: near “,”: syntax error, select where in

i have a sql code, i use python 3.6

SELECT a,b,c
FROM belge_yeni 
WHERE (a,b) 
IN (SELECT a,b FROM belge_yeni GROUP BY a,b HAVING count(*) >1)  
ORDER BY a, b DESC

i can run python 3.8,
but i have sqlite3.OperationalError: near ",": syntax error" in python 3.6

i seen this link
https://code.djangoproject.com/ticket/30027
but i dont understood
Thank you

TY FOR Help, solved my problem Python Sqlite 3.6, 3.8 version problem.

select m.*
from belge_yeni m
where (
    select count(*) 
    from belge_yeni m1 
    where m1.a = m.a and m1.b = m.b
) > 1 order by b

Your query is syntactically correct if the version of SQLite you are using is 3.15.0+.
I suspect that it is older, so ROW VALUES are not supported.
Here is an equivalent query that uses EXISTS :

SELECT t.a, t.b, t.c
FROM belge_yeni t 
WHERE EXISTS (SELECT 1 FROM belge_yeni WHERE a = t.a AND b = t.b AND rowid <> t.rowid)
ORDER BY t.a, t.b DESC

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