我有一个查询,其中包含多个产品的类别。我也在查询和输出中根据类别和产品对其进行分组。但是,在构建 API 代码时,我遇到了它们之间逗号的问题。到目前为止,我已经在所有地方都放了逗号,最后也是,但我不想将它们添加到类别或产品组的末尾。这是查询:
SELECT P.PRODUCT_ID,P.PRODUCT_NAME,PC.PRODUCT_CAT,PC.PRODUCT_CATID,PR.PRICE,PR.MONEY,PC.HIERARCHY
FROM PRODUCT_CAT PC
LEFT OUTER JOIN PRODUCT P ON P.PRODUCT_CATID=PC.PRODUCT_CATID
LEFT OUTER JOIN PRICE PR ON P.PRODUCT_ID=PR.PRODUCT_ID
WHERE P.IS_SALES=1 AND P.IS_EXTRANET=1 AND PR.PRICE IS NOT NULL
GROUP BY PC.HIERARCHY,PC.PRODUCT_CAT,P.PRODUCT_ID,P.PRODUCT_NAME,PC.PRODUCT_CATID,PR.PRICE,PR.MONEY
ORDER BY PC.HIERARCHY,P.PRODUCT_NAME
和我的输出:
{"status":"ok","count":<cfoutput>#row#</cfoutput>,"data":[
<cfoutput query="get_json" group="product_catid">
{"cat":#product_cat#,"cat_id":#product_catid#,"products":[
<cfoutput group="product_id">
{"id":#product_id#,"name":#product_name#,"price":#tlformat(price,2)#,"currency":#money#},<!-- i dont want this comma to be added in the end of the products group --->
</cfoutput>
]},<!-- i dont want this comma to be added in the end of the categories group --->
</cfoutput>
]}
您可以在这里查看它的实时输出。如您所见,即使在分组产品的末尾以及最后,在类别组的末尾也添加了逗号,但我不希望它们在那里。我怎样才能解决这个问题?