Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2009
    Posts
    2

    Confused about a larger db then im use to working with...

    I haven't designed or worked with big DB's.

    The site I am working on tracks Friend codes for a game i play...

    I have one table called codes that looks like this:

    Codes > id - int - auto inc - primary key
    > code - varchar
    > type - int (For identify owners or certian codes)
    > lseen - datetime
    > created - datetime
    > banned - int

    Users > id - int - auto inc - primary key
    > username - varchar
    > password - varchar
    > created - datetime
    > ip - int


    The thing that I am planning to do is track what codes my users have used.

    How should I go about doing this?

    Mysql....

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    How should I go about doing this?
    Not sure how the type field is used in codes. Can a user use a code more than once and, if so, would you want to store each use? Anyway I'll take a wild stab at things by adding the table UserCodes :

    Code:
    create table UserCodes(
      user_id
      code_id
      date_used
    )

  3. #3
    Join Date
    Mar 2009
    Posts
    2
    THey con only use the code once...

    So when i pull it out through php I only want the codes they havent used.....

    The table u mentioned is a one i thought of but I was having problems about figuring out how i would echo out all the codes ....

    Me thinking... "Select * FROM codes WHERE code != UserCodes.code" <<<< this is where I am running into and idea problem.....

  4. #4
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Quote Originally Posted by Krrose27
    So when i pull it out through php I only want the codes they havent used.....
    Code:
    Select code
    FROM   Codes 
    WHERE  not exists(
                select 1 
                from   UserCodes uc
                where  user_id = YourUser 
                       and uc.code_id = Codes.id )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •