Steinar Midtskogen <stei...@latinitas.org> wrote:
> [Igor Tandetnik]
>> Try something like this:
>> 
>> select timestamp, value1, ..., value6 from
>> (select timestamp from tab1
>>  union
>>  select timestamp from tab2
>>  union
>>  select timestamp from tab3)
>> left join tab1 using (timespamp)
>> left join tab2 using (timespamp)
>> left join tab3 using (timespamp);
> 
> Wonderful!  It also eliminates the need to list all the nulls and
> values, and as a bonus it gets ordered by timestamp whereas the
> previous solution required an "ORDER BY timestamp"

If you need a particular order, it's best to add an explicit ORDER BY. 
Otherwise, you are at the mercy of an implementation. Your current version of 
SQLite chooses an execution plan that happens, by accident, to produce rows in 
the desired order. Tomorrow you upgrade to a new version, and it chooses a 
different execution plan that results in a different order.
-- 
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to