小程序云开发数据库查询 如何返回唯一不同的值?

小程序 文章 2021-02-02 15:01 759 0 全屏看文

AI助手支持GPT4.0

小程序云开发数据库查询 如何返回唯一不同的值?Mini Program Cloud Development Database Query How to return unique and different values?

小程序云开发数据库查询 如何返回唯一不同的值?

小程序云开发数据库查询 如何返回唯一不同的值?

例如订单列表,有 id name price 等字段,我需要查询所有的产品名称也就是name的值,有重复的就返回唯一的值

How to return a unique and different value for the query of small program cloud development database? For example, in the order list, there are fields such as ID, name, price, etc. I need to query all the product names, that is, the value of name. If there are duplicate products, the unique value will be returned

回答:

Stephen:

聚合函数 group 就能搞定

阿良:查询出来是一个数组,不能有重复的
Mr.Zhao:我怎么知道你咋查的?我咋知道你数据结构是啥?我可能知道?
阿良:我是请教,例子写在题外了
Mr.Zhao:我知道你结构是啥,我知道你想怎么查?你请教啥了?你明白我意思吗?
阿良:例如查询订单列表,遇到重复的产品名称只返回一个
Mr.Zhao:跟没说一样。你把你集合的数据亮出来,再把想要的结果发出来,学会提问
阿良:订单列表,ID name price 这些字段,我需要查出所有订单的产品名称
阿良:也就是所有的name
阿良:谢谢,谢谢
阿良:

例如查询订单列表,遇到重复的产品名称只返回一个值

-EOF-

AI助手支持GPT4.0