Jump to content
MakeWebGames

Tables and Query's


Recommended Posts

I'm trying to understand how tables associate with one another and the question I have is if I set up a users table with 3 field names of char1_id, char2_id, and char3_id and auto_increment them will those id's increment like the userid does?

For example the way I would like this to work is like this:

Player one enters his info and this is the table

userid = 1

char1_id = 1

char2_id = 2

char3_id = 3

Player two enters his info

userid = 2

char1_id = 4

char2_id = 5

char3_id = 6

Then to update any tables associated with that character would I then update with a query that references both the userid and the char1_id. ( WHERE userid = userid AND char1_id = char1_id) or would I simply update it with a single WHERE char1_id = char1_id.

I want it so that each char has a unque number ... but the 3 chars are then associated with just one unserid. If I do it the way I have written it above ... will that accomplish this.

Link to comment
Share on other sites

This is only for mysql databases: auto_increment values are linked to a field, not a table. You can use as many auto_increments per table as you'd like though, so an easy solution is to create an auto_increment on userid, increase 1 (sequence will go 1,2,3 ...) and create an auto_increment for the field char1_id, char2_id, char3_id, and set the increase to 3 (sequence will go 3,6,9). make sure to set the starting value though! This way you'll accomplish what you originally wanted and with unique numbers for whatever char.

How you should your update query can only be said if we know the structure of that table. If it holds a valid reference to what char it points, you should not need the userid as char_id's are unqiue.

 

Topic moved to technics -> mysql, this has nothing to do with the mcc game engine. Please post correctly!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...