Need some sql help, bigtime:)

Discussion in 'Databases' started by Laceygirl, Apr 2, 2007.

  1. #1
    I'll walk you through my problem.

    Sql isn't my cup-o-tea, I got an arcade game site.

    Here's the issue I'm having:


    I just grabbed a hold of a gamepack with loads of games. The problem is the sql it came with is not or my script(av arcade script). I don't know what it's for. It has many different structure table lines(is that what it's called?).

    For the games my sql table has the following:
    `id`
    `name`
    `description`
    `url`
    `catergory_id`
    `hits`
    `published`
    `user_submit`
    `width`
    `height`
    `image`


    So my sql entry would be like this:
    But the sql for this other gamepack I want in has got a different setup with the following:
    `id`
    `nameid`
    `name`
    `desc`
    `time'
    `width`
    `height`
    `cat`
    `rating`
    `type`
    `authorsite`
    `authorname`
    `gameurl`
    `code`
    `playcount`
    `weeklyplays`
    `flags`
    `instructions`
    `keywords`
    `disphtml`
    `disphtmlcode`
    `order`
    `active`

    And one line of that would be like this:

    What is an easy solution to get a the sql to work to put in these games. There's like 3000 of them. I don't have to manually change them all, right?
     
    Laceygirl, Apr 2, 2007 IP
  2. SoKickIt

    SoKickIt Active Member

    Messages:
    305
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #2
    Let's say that table is called "games".


    1. Create new table (games_new) with the structure described above.
    2. Insert all new games into that table.
    3. Edit "games_new" and make it look like the "games" table. Drop fields you don't need and rename other fields to match fields in your old table (games).
    4. Run this query:

    INSERT INTO games (name, description, url, catergory_id, hits, published, user_submit, width, height, image) SELECT name, description, url, catergory_id, hits, published, user_submit, width, height, image FROM games_new
    Code (markup):
    5. Drop "games_new" cause you don't need it anymore.
     
    SoKickIt, Apr 2, 2007 IP