Results 1 to 4 of 4
  1. #1
    The Eternal Optimist zimmy's Avatar
    Join Date
    January 18th, 2005
    Location
    NC
    Posts
    696
    MySQL question
    Hoping for a simple way to do this:

    Lets say I have a database that has a table with 10 fields

    How do I select 5 of these fields and make a new table keeping all the data in place?

    Thanks



    ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*

    The big shots are only the little shots who keep shooting.
    -Christopher Morley

  2. #2
    Moderator MichaelColey's Avatar
    Join Date
    January 18th, 2005
    Location
    Mansfield, TX
    Posts
    16,232
    It sounds like you want to use INSERT ... SELECT.
    Michael Coley
    Amazing-Bargains.com
     Affiliate Tips | Merchant Best Practices | Affiliate Friendly? | Couponing | CPA Networks? | ABW Tips | Activating Affiliates
    "Education is the most powerful weapon which you can use to change the world." Nelson Mandela

  3. #3
    The Eternal Optimist zimmy's Avatar
    Join Date
    January 18th, 2005
    Location
    NC
    Posts
    696
    Thanks Michael - just what I needed.



    ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*

    The big shots are only the little shots who keep shooting.
    -Christopher Morley

  4. #4
    Fear and Arrogance jrrl's Avatar
    Join Date
    January 18th, 2005
    Location
    Pittsburgh
    Posts
    485
    Quote Originally Posted by zimmy
    Lets say I have a database that has a table with 10 fields

    How do I select 5 of these fields and make a new table keeping all the data in place?
    You can do this:

    Code:
    CREATE TABLE newtable SELECT a, b, c, d, e FROM oldtable;
    -John.
    There's a reason army's wear uniforms even though it makes them easier to spot. Sometimes that's what you want. Uniforms suggest organization, power, and numbers. These, in turn, inspire fear. And, as any good operative knows, there is no more effective weapon than fear.

    Hosting Comparison - HostScope - jrrl.com

  5. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Question on Match Function of MySql
    By UKJ in forum Programming / Datafeeds / Tools
    Replies: 5
    Last Post: September 18th, 2005, 12:28 AM
  2. Update Command question in MySQL
    By hotspice in forum Programming / Datafeeds / Tools
    Replies: 5
    Last Post: July 11th, 2005, 06:08 PM
  3. PHP/MySQL syntax question?
    By AcuraImport in forum Programming / Datafeeds / Tools
    Replies: 8
    Last Post: April 18th, 2004, 06:25 PM
  4. PHP4 and mysql question
    By AWaR in forum Programming / Datafeeds / Tools
    Replies: 7
    Last Post: February 2nd, 2002, 04:57 PM

Posting Permissions

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