I was trying to do like a command with disord.js and the MAX() function that sorts the highest number of timescountedweek column, and also that row's ID and username.
This is what I have:
let sql = `SELECT
username,
userid,
timescountedweek
FROM
userstats
WHERE
timescountedweek = (SELECT max(timescountedweek) FROM userstats);`
db.get(sql, (err, row) => {
if (err) {
return console.error(err.message);
}
console.log(row.username)
console.log(row.timescountedweek)
console.log(row.userid)
})
There is an issue here if I start this and it logs those 3 "rows" It logs the correct username and timescountedweek, but the userid is something totally different.
How it logs:
!2019#4392 41 235506020267327500
How it should log:
!2019#4392 41 336936521120874497
image of the database: https://i.stack.imgur.com/SLsfE.png