Mysql: How to get COUNT(*) variable

Created on 17 Sep 2016  路  1Comment  路  Source: mysqljs/mysql

Hello,

Can you please tell me, how to get value of COUNT(*)?

Mysql query - > SELECT COUNT(*) from table

rows [0] =  RowDataPacket {'COUNT(*)': 4}

rows[0].COUNT and other is not working.

question

Most helpful comment

Hi @enhaster, I know you closed this issue shortly after you opened it, so I hope you got your answer. For some additional information, you should be able to access it by using rows[0]['COUNT(*)'] according to the output you have above. In addition, if you use the SQL AS to name the column, it can make it easier to access in JavaScript. For example, if you use COUNT(*) AS count, then in this module, you can access using just rows[0].count.

>All comments

Hi @enhaster, I know you closed this issue shortly after you opened it, so I hope you got your answer. For some additional information, you should be able to access it by using rows[0]['COUNT(*)'] according to the output you have above. In addition, if you use the SQL AS to name the column, it can make it easier to access in JavaScript. For example, if you use COUNT(*) AS count, then in this module, you can access using just rows[0].count.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

acefxlabs picture acefxlabs  路  4Comments

EdoardoPedrotti picture EdoardoPedrotti  路  3Comments

abou7mied picture abou7mied  路  4Comments

JCQuintas picture JCQuintas  路  3Comments

tbaustin picture tbaustin  路  3Comments