mardi 10 février 2015

sqlite select all rows where some columns are in set of possible values


col0 col1 col2 A B C
0 0 1 1 2 3
0 1 1 1 2 3
0 0 1 1 2 3
0 2 0 1 2 3
0 1 1 1 2 3


Hello, I have a table where some of the columns are col0, col1, col2. First of all I want to find each combination which meet some condition. Let's say for simplicity to find each triple which is more than once in database (group by and having is required in my more complicated real case):



SELECT col0,col1,col2 FROM table GROUP BY col0,col1,col2 HAVING COUNT(*) > 1


Gives me something like:



col0 col1 col2
0 0 1
0 1 1


Now I want to select (actually delete) all such rows which contain one of those col0,col1,col2 combinations.


So something like:



SELECT * FROM table WHERE (col0,col1,col2) IN (...select above...)


But that gives me an error, I guess just one column is allowed for WHERE clause in SQLite. How to proceed? Thank you.


Aucun commentaire:

Enregistrer un commentaire