0

lastModified在特定属性之后,我正在从 jcr 检索一组节点。但是对于某些节点,在这种情况下它没有lastModified属性,我的查询必须查找jcr:createdDate. 它将如何实现?这是我的查询

SELECT * FROM [nt:base] AS s WHERE [cq:lastModified] > CAST('2014-05-08T17:36:00.400+05:30' AS DATE)

谢谢

4

2 回答 2

2

我认为使用 OR 条件应该适用于您的情况,因为 lastModified 不大于指定日期的节点显然不会让 createdDate 大于它。

如果 lastModified 不存在,它将检查 createdDate 并相应地生成结果

SELECT * FROM [nt:base] AS s 
WHERE [cq:lastModified] > CAST('2014-05-08T17:36:00.400+05:30' AS DATE) 
OR [jcr:created] > CAST('2014-05-08T17:36:00.400+05:30' AS DATE)
于 2014-05-14T08:02:40.027 回答
2

属性缺失的测试如下所示

[cq:lastModified] IS NULL

您的查询可以重写为:

SELECT *
FROM [nt:base] AS s
WHERE
    [cq:lastModified] > CAST('2014-05-08T17:36:00.400+05:30' AS DATE)
    OR ([cq:lastModified] IS NULL
        AND
        [jcr:created] > CAST('2014-05-08T17:36:00.400+05:30' AS DATE))
于 2014-05-14T13:50:52.533 回答