1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

MySQL help!

Discussion in 'MySQL' started by thr3146, Jun 5, 2013.

  1. #1
    I am new at MySQL and could use some help.

    I am creating a games DB and now have 3 entries for the same games and need to delete 2 of them.

    If someone could explain to me in how to get these duplicates out in "Very" simple terms I would really appreciate it.

    Thanks in advance
     
    thr3146, Jun 5, 2013 IP
  2. PYO

    PYO Member

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #2
    MySQL can only find such duplicates. You must remove them one by one yourself.
     
    PYO, Jun 5, 2013 IP
  3. aidanriley629

    aidanriley629 Banned

    Messages:
    429
    Likes Received:
    23
    Best Answers:
    3
    Trophy Points:
    175
    #3
    The easiest way would be to download the WAMP server, use their PHPMyAdmin tool and just delete them.
     
    aidanriley629, Jun 8, 2013 IP
  4. abraham26

    abraham26 Member

    Messages:
    73
    Likes Received:
    6
    Best Answers:
    2
    Trophy Points:
    48
    #4
    abraham26, Jun 8, 2013 IP
  5. thr3146

    thr3146 Active Member

    Messages:
    182
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #5
    After playing around with it more I figured the easiest way was to delete it and start over, I think that saved more time but thank you all for the responses and now know where to look for help now.
     
    thr3146, Jun 10, 2013 IP
  6. dwirch

    dwirch Well-Known Member

    Messages:
    239
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    135
    #6
    Be sure to specify a unique key in your table structure. Something like RecordID. This should be an auto-incrementing, integer field.

    Something like the below will create a table with a GameID field (Primary Key), GameTitle, GameInfo, and GameRating:

    CREATE TABLE `games` (
      `GameID` int(11) NOT NULL AUTO_INCREMENT,
      `GameTitle` text DEFAULT NULL,
      `GameInfo` longtext DEFAULT NULL,
      `GameRating` int(11) DEFAULT NULL,
      PRIMARY KEY (`GameID`)
    ) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=latin1;
    /*!40101 SET character_set_client = @saved_cs_client */;
    Code (markup):
    By referencing the primary key as well as the game title, you can build links on your web page or in your application to work with each entry, even if all info is the same, since the GameID field will be different and unique for each record.

    For example, if you have 7349 games (records in the table), and you want to delete and you want to delete the record for the duplicate Pac Man entry, which happens to be GameID of 3025, you would just send the following to the db from your code:

    delete from games where gameid=3025
    Code (markup):
    The HTML for a link would look something like this:

    <a href="delete_game_record.php?gid=3025">Delete Game</a>
    Code (markup):
    Now, you can have other records that reference Pac Man, but only the duplicate or "bad" entry is removed.

    I'll leave it to you to build the PHP code (I assume that is what you are coding in) to retrieve the GameID from the DB, and build the link.
     
    dwirch, Jun 23, 2013 IP