mysql中的行值选择最大查询返回undefined

时间:2015-05-28 13:19:32

标签: mysql node.js

我想在我的表中查找max id值,所以我使用了以下查询

   connection.query ('SELECT * FROM report', 
        function (err,rows){
        if (err) throw err;
        if (!rows.length)  var idTest = 0

        else {
            connection.query ('SELECT MAX(id) FROM report ' , 
                function (err,results , fields){

                console.log (results)
                console.log (fields)
                console.log (results[0].id)  // returns undefined
                console.log (results.id) // returns undefined
                });
        }

});

for console.log(results)我得到:

  

[{'MAX(id)':2}]

但不知怎的,我无法找回2号码 有什么建议吗?

0 个答案:

没有答案
相关问题