# How to convert a table

**URL:** <https://forum.kirupa.com/t/how-to-convert-a-table/293960>\
**Category:** programming\
**Created:** [August 6, 2009, 9:39am UTC](https://forum.kirupa.com/t/how-to-convert-a-table/293960 "2009-08-06T09:39:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gilbertsavier](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@gilbertsavier](https://forum.kirupa.com/u/gilbertsavier)\
**Post date:** [August 6, 2009, 9:39am UTC](https://forum.kirupa.com/t/how-to-convert-a-table/293960/1 "2009-08-06T09:39:38Z")

</div>

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?
