Get the sibling value of a SQLITE value

48 Views Asked by At

I have a SQLite Table:

+---------+-----------+-----------+-----------+
| userID  | balance   | ledger    | lasttopup |
+---------+-----------+-----------+-----------+
|       1 | 90        |       780 |  12/10/18 |
|       2 | 180       |         0 |  4/11/18  |
|       3 | 270       |        12 |  13/10/18 |
|       4 | 360       |       109 |  11/10/18 |
+---------+-----------+-----------+-----------+

And I am accessing the column ledger via:

 const conn = new require('better-sqlite3')('../../data/databases/casino.sqlite3');     
const balances = conn.prepare(`SELECT * FROM "${msg.guild.id}"`).all().map(e => e.ledger)

And I want to get the userID which pertains to the respective ledger entry. Visual: Visualization

And then perform an action on the ledger value.

But I am unsure of how to retrieve the userID.

Any help will we appreciated!

[LIBRARIES]
DiscordJS
better-sqlite3

~Thanks

0

There are 0 best solutions below