1

I would like to get the amount of a MySQL-database, then I query "SELECT COUNT(*) FROM articles_table" and got "[ RowDataPacket { 'COUNT(*)': 13 } ]"

I have tried to 'console.log(data[0].COUNT)', but I got a undefined message....

Could anyone tell me How do I do to get the number 13 with javascript?

Thank you very much!

Sylvia
  • 257
  • 2
  • 6
  • 16

1 Answers1

4

First, give the aliases to your expression column in SELECT statement i.e. for "COUNT(*)" as below.

SELECT COUNT(*) as cnt FROM articles_table

Then, try to use

console.log(data[0].cnt)