- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两个表,我需要从每个表中选择一列。
这必须在单个查询中完成。
好消息是这两列以正确的方式排序,并且它们都包含相同数量的行。
现在,我知道我可以通过 rowid 加入两个表,但它很慢,因为它必须进行比较。在我的情况下,没有必要......我需要更像水平 UNION ALL 来连接两列长度相等的列。
在 SQLite 3 中是否有可能发生这样的事情?
谢谢。
表 1:
| timestamp | FIELD1 | FIELD2 | ...
| 12345678 | 000000 | 000000 | ...
| 00154789 | 000000 | 000000 | ...
| temperature |
| 1000000000 |
| 2000000000 |
| timestamp | temperature |
| 12345678 | 1000000000 |
| 00154789 | 2000000000 |
SELECT timestamp, temperature
FROM TABLE1 INNER JOIN TABLE2 ON TABLE1.rowid = TABLE2.rowid;
最佳答案
Two or more simple SELECT statements may be connected together to form a compound SELECT using the UNION, UNION ALL, INTERSECT or EXCEPT operator. In a compound SELECT, all the constituent SELECTs must return the same number of result columns. As the components of a compound SELECT must be simple SELECT statements, they may not contain ORDER BY or LIMIT clauses. ORDER BY and LIMIT clauses may only occur at the end of the entire compound SELECT.
A compound SELECT created using UNION ALL operator returns all the rows from the SELECT to the left of the UNION ALL operator, and all the rows from the SELECT to the right of it. The UNION operator works the same way as UNION ALL, except that duplicate rows are removed from the final result set. The INTERSECT operator returns the intersection of the results of the left and right SELECTs. The EXCEPT operator returns the subset of rows returned by the left SELECT that are not also returned by the right-hand SELECT. Duplicate rows are removed from the results of INTERSECT and EXCEPT operators before the result set is returned.
关于join - 水平 UNION ALL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5970814/
我是一名优秀的程序员,十分优秀!