(SQLite) Get a name from an integer primary key column
#1

I'm currently trying to learn how to script SQLite for educational purposes (to further my skill), however in the process of attempting to make a dynamic system where I've two tables, let's call them users and objects, I've ran into a problem.

The users table has a column with the type integer primary key, I would like to know how I can retrieve the value from this column and load it into a variable that assigns ownership of the object when the server is started. The ownership column in the objects table will be 0, if the object has no owner, or a number higher than 0 if an owner is assigned to said object.

Currently, the command where I assign ownership of an object is working fine, it saves the integer primary key of the user into the owner column in the objects table. However, when the server loads I want the script to check the row of the object and select the owner column, followed by sending another query which goes into the users table and extracts the name of the row that has the same integer primary key as the owner column in the owners table.

In short, I want to retrieve the name of the owner of an object when the server starts.
Reply
#2

Bump.
Reply
#3

Uh something like
Code:
SELECT name FROM users WHERE id=%i
?
Reply
#4

Could you elaborate on that?

EDIT: This has been solved by myself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)