I have a player table, which is made up of fields:
id SERIAL NOTNULL AUTO_INCREMENT (this is the primary key, auto increment so each player is assigned a unique key)
player VARCHAR (just a text player name)
player_id VARCHAR(text matching the players in-game number)
then i have a locations table, with fields:
lid SERIAL NOTNULL AUTO_INC (primary key, each location is assigned a unique key)
pid INT NOTNULL (this is supposed to match the id of the player table, so this location entry gets associated with the players id)
location VARCHAR (text, one of many player's starbase locations)
econ VARCHAR (text, base stats)
def VARCHAR (text, base stats)
Question is:
how do i create an INSERT statement that inserts the players name into the player table, then uses the id from the player table, inserts that into the pid table of my locations table? then how do i query the DB to find all locations of any player, using the pid number assigned to each location?
any help is appreciated! and by the way its a very fun game, quite addictive!
id SERIAL NOTNULL AUTO_INCREMENT (this is the primary key, auto increment so each player is assigned a unique key)
player VARCHAR (just a text player name)
player_id VARCHAR(text matching the players in-game number)
then i have a locations table, with fields:
lid SERIAL NOTNULL AUTO_INC (primary key, each location is assigned a unique key)
pid INT NOTNULL (this is supposed to match the id of the player table, so this location entry gets associated with the players id)
location VARCHAR (text, one of many player's starbase locations)
econ VARCHAR (text, base stats)
def VARCHAR (text, base stats)
Question is:
how do i create an INSERT statement that inserts the players name into the player table, then uses the id from the player table, inserts that into the pid table of my locations table? then how do i query the DB to find all locations of any player, using the pid number assigned to each location?
any help is appreciated! and by the way its a very fun game, quite addictive!
Comment