SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: MySQL table

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    Australia
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL table

    Hi

    I've got a MYSQL table which only has one field. At the moment they are around 2000 rows. I want create more tables and break up the existing table so that there are only 300 rows in each table.

    What MySql command do I need to do this. I was thinking something along the lines of putting in id and then executing some query.

    What would this query be.

    Thanks,
    Ajay

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have removed your other thread asking this question. If a thread is in the wrong forum you can contact an Advisor and ask for it to be moved instead of creating a new thread

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,322
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    the command for creating more tables is CREATE TABLE

    i'm just curious, what's in that column and why do you feel you need more tables?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    Australia
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know how to create a table but I need to basically copy a table but only copy the first 300 records into the table.

    How do I do this.

    Thanks

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,322
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    the first 300 based on what column?

    insert into table2 (foo, bar)
    select qux, baz
    from table1
    order by somecolumn
    limit 300
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  6. #6
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    Australia
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks that works. Now how do I get the next 300 then the next 300 etc.

    Thanks A lot,
    Ajay

  7. #7
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like rudy asked, I'm also curious why you have a table like this, and why you needed to split it up. Clue us in?

    Getting records 301-600:
    insert into table2 (foo, bar)
    select qux, baz
    from table1
    order by somecolumn
    limit 300, 300

    Getting records 301-600:
    insert into table2 (foo, bar)
    select qux, baz
    from table1
    order by somecolumn
    limit 600, 300

    You get the idea.


Bookmarks

Posting Permissions

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