How to convert a table

Discussion in 'MySQL' started by gilbertsavier, Jul 17, 2009.

  1. gilbertsavier

    gilbertsavier New Member

    Joined:
    Jun 25, 2009
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    Hi, all,

    I have a problem to convert table content based on existing content:

    DROP TABLE IF EXISTS `list`;
    CREATE TABLE `list` (
    `FACILITY` varchar(30) NOT NULL,
    `PRODUCT` varchar(30) NOT NULL,
    `SEGMENT` varchar(30) NOT NULL,
    PRIMARY KEY (`FACILITY`,`PRODUCT`,`SEGMENT`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    Let's say I know,
    I have 2 FACILITY: AUSTIN, BOSTON;
    (by

    select distinct facility from list;

    )
    I have 2 PRODUCT: A, B;
    (by

    select distinct product from list;

    )
    I have 2 SEGMENT: BIG, SMALL;
    (by

    select distinct segment from list;

    )

    the Total combination could be 2*2*2=8

    Now the current table "list" contains below data (3 records):
    AUSTIN, A, BIG;
    AUSTIN, B, SMALL;
    BOSTON, A, SMALL;

    How can I tell the other 5 combination by MYSQL?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice