0

我的标题问题,所以如果我有:

SELECT * FROM tbl WHERE date BETWEEN "date[0][start]"
AND "date[0][end]" OR date BETWEEN "date[1][start]" AND "date[1][end]"

我可以以某种方式将设备中的结果与 where 子句分开吗

4

1 回答 1

1

每个条件的计算结果为 FALSE (0) 或 TRUE (1)。可以选择表达式的结果作为值,甚至可以按这些值对结果进行排序:

SELECT
    col1, col2, ..., coln,
    date BETWEEN "date[0][start]" AND "date[0][end]" AS first,
    date BETWEEN "date[1][start]" AND "date[1][end]" AS second
FROM tbl
WHERE date BETWEEN "date[0][start]" AND "date[0][end]"
OR date BETWEEN "date[1][start]" AND "date[1][end]"
ORDER BY first 
于 2012-12-12T12:32:50.257 回答