0
votes

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
1
For the example you may written sql keyword in UPPERCASE, and change your variable names to more easyily readable ones - azro
ty for help, ty - eroniko
Your query is fine, but maybe you are using a version of SQLite older than 3.15.0 which does not support row_values. Execute select sqlite_version() to check the version. - forpas
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 - eroniko

1 Answers

1
votes

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