On 11 May 2010 08:49, Andrea Galeazzi <galea...@korg.it> wrote: > I've got this table > TABLE T ( > id INTEGER NOT NULL UNIQUE, > file_type VARCHAR(10) NOT NULL) > My goal is to check if a certain selection has all the same values. I > thought that the following statement should be enough for my aim: > SELECT (SELECT file_type FROM T T1, T T2 WHERE T1.id IN (1,4,5....) AND > T2.id IN (1,4,5....) AND T1.file_type <> T2.file_type LIMIT 1) IS NULL > Does anyone know a fastest query to achieve that?
I've not checked performance, but you can eliminate the join with: select (select count( distinct file_type ) from t where id in( 1,4,5 ) )=1; > Cheers. Regards, Simon _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users