执行COUNT函数时出现OCommandSQLParsingException错误

时间:2015-01-06 03:46:14

标签: java orientdb nosql

我正在使用计数的Java API在OrientDB中尝试一个简单的查询,但我得到了异常:

  

选择产品。@ rid as rid,
                       product.brand作为品牌,
                          product.description as description,
                          product.imageURL as imageURL,
                          product.searchTags as searchTags,
                          product.name_en为name_en,
                          product.name_ar为name_ar,
                       product.categoryID.RefKey为catID,
                       product.categoryID为categoryRid,
                       product.categoryID.name.name_en为category_en,
                          product.categoryID.name.name_ar为category_ar,$ offerCount
                          来自Inf_RecentProducts                        LET $ offerCount =从Inf_Offer中选择COUNT(*)                                         priceID.productID.refKey = product.refKey                                           和goodTill> SYSDATE()                    其中user.loginName ='nooruls143'LIMIT 5

例外是

com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error on parsing command at position #911: Invalid keyword 'COUNT' Command: select product.@rid as rid, product.brand as brand, product.description as description, product.imageURL as imageURL, product.searchTags as searchTags, product.name_en as name_en, product.name_ar as name_ar, product.categoryID.RefKey as catID, product.categoryID as categoryRid, product.categoryID.name.name_en as category_en, product.categoryID.name.name_ar as category_ar,$offerCount from Inf_RecentProducts LET $offerCount = select COUNT(*) from Inf_Offer where priceID.productID.refKey = product.refKey where user.loginName = 'nooruls143' LIMIT 5

我使用正确的语法吗?非常感谢。

谢谢, Noorul

1 个答案:

答案 0 :(得分:0)

如果要将查询的值分配给变量,则应执行以下操作:

...
let $var = ( SELECT ... )
...

请参阅this link