0
今天我的注意力不集中,或者Slick的入门文档没有很好的设计。 所以在查询/工会节他们有这样的片段:Slick文档中的错误示例?
val q1 = coffees.filter(_.price < 8.0)
val q2 = coffees.filter(_.price > 9.0)
val unionQuery = q1 union q2
// compiles to SQL (simplified):
// select x8."COF_NAME", x8."SUP_ID", x8."PRICE", x8."SALES", x8."TOTAL"
// from "COFFEES" x8
// where x8."PRICE" < 8.0
// union select x9."COF_NAME", x9."SUP_ID", x9."PRICE", x9."SALES", x9."TOTAL"
// from "COFFEES" x9
// where x9."PRICE" > 9.0
val unionAllQuery = q1 ++ q2
// compiles to SQL (simplified):
// select x8."COF_NAME", x8."SUP_ID", x8."PRICE", x8."SALES", x8."TOTAL"
// from "COFFEES" x8
// where x8."PRICE" < 8.0
// union all select x9."COF_NAME", x9."SUP_ID", x9."PRICE", x9."SALES", x9."TOTAL"
// from "COFFEES" x9
// where x9."PRICE" > 9.0
然后他们说: Unlike union which filters out duplicate values, ++ simply concatenates the results of the individual queries, which is usually more efficient.
我觉得有没有通过q1
和q2
产生重复。所以这是一个错误的查询例子,他们提供了说明union
和++
之间的真正区别,或者我没有看到重要的东西。你们能帮忙吗?