Hi Wying, > Create View MyView1 as > SELECT > t1.A + t2.A as Col1 > , t1.B + t2.B as Col2 > , t2.C as Col3 > ... > > Create View MyView2 as > SELECT > t1.A + t3.A as Col1 > , t1.B + t3.B as Col2 > , t3.C as Col3 > ...
> In the users' query:- > SELECT > ... > FROM > MyView1 v1 > JOIN MyView2 v2 ON v1.Col1 = v2.Col1 > AND v1.Col2 = v2.Col2 You can only index stored values, ie columns in a table. You can't index the results of an on the fly calculation (ie views), such as addition. This is not a limitation on views but on indexes. You can only index what's actually there (ie values stores in a row/column). So you would have the same problem without views. Since you are searching on the sum of values in two columns equalling the sum of two other columns, you can only index those sums if you store the sums in a table. One way to do this would be to use a table in place of your view: create table MySums1 as select T1.A + T2.A as Col1 , T1.B + T2.B as Col2 , T2.C as Col3 from Table1 t1 , Table2 t2 Then you can index Col1, Col2, Col3 etc. You could automatically update the sums table MySums1 using triggers on your primary tables. Tom BareFeet -- Comparison of SQLite GUI applications: http://www.tandb.com.au/sqlite/compare/?ml _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users