N
N
nikita000012020-12-23 12:50:14
MySQL
nikita00001, 2020-12-23 12:50:14

How to use the data received after a query in mysql?

I have created a mysql query to the database which should return the largest value of the ID column, i.e. get information about the last ID. When I try to display the result, I get [object Object]. I need a numeric value.
The terminal displays the entire database first, and then the maximum value of the ID field.
If I use just result instead of result[0] when displaying, then nothing changes.
5fe3128d30ddd018327970.png5fe31295c4570841736149.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2020-12-23
@nikita00001

Did you try to output like this?
console.log('result:', result[0]);

Y
Yukkona, 2020-12-24
@Yukkona

You get an Object (RowDataPacket or RowDataPacket[], to be more precise) as an output, and not a number,
refer to the documentation of your connector to the database, how to get the data you need from it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question