eroniko
eroniko

Reputation: 1

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

Upvotes: 0

Views: 1505

Answers (1)

forpas
forpas

Reputation: 164139

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

Upvotes: 1

Related Questions