简体   繁体   English

node-postgres返回多个array_length()列?

[英]node-postgres returning multiple array_length() columns?

I have 3 array columns and i am trying to get the count for each of these arrays but node-postgres is only returning one of them which is the last array_length() passed in the SQL statement. 我有3个数组列,我试图获取每个数组的计数,但是node-postgres仅返回其中一个,这是SQL语句中传递的最后一个array_length()。 I passed the same sql query using the postgres console and it returned all the results. 我使用postgres控制台传递了相同的sql查询,它返回了所有结果。

Ok figured it out, the array query needs to be wrapped in brackets 确定了,数组查询需要放在方括号中

(array_length(friends,1),array_length(clients, 1),array_length(venues, 1)) 

and this will return for eg (3,3,7) , otherwise only the last query will return (7) . 并且将返回例如(3,3,7) ,否则仅最后一个查询将返回(7)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM