I have two tables and I need to select one column from each of them. This must be done in a single query. The good news is that the two columns are ordered the right way and they both contain the same number of rows. Now, I know I could JOIN the two tables by rowid, but it is slow as it has to do that comparison. In my case it is not necessary... I need something more like horizontal UNION ALL to concatenate two columns of equal length.
Is anything like that possible in SQLite 3?
Thanks.
TABLE1:
| timestamp | FIELD1 | FIELD2 | ...
| 12345678 | 000000 | 000000 | ...
| 00154789 | 000000 | 000000 | ...
TABLE2:
| temperature |
| 1000000000 |
| 2000000000 |
REQUIRED SELECT OUTPUT
| timestamp | temperature |
| 12345678 | 1000000000 |
| 00154789 | 2000000000 |
QUERY:
SELECT timestamp, temperature
FROM TABLE1 INNER JOIN TABLE2 ON TABLE1.rowid = TABLE2.rowid;
This takes ~0.75s in my testing app. When I do two separate SELECTs and join the outputs later in my program it takes ~0.4s, but it is not very convenient. The fastest way (~0.23s) is to have both columns in one table, but it is wasteful as I have multiple versions of TABLE2 that share the same timestamps.