mysql - SQL query to extract some rows from one row of a table -



mysql - SQL query to extract some rows from one row of a table -

i have table like:

create table company ( id integer auto_increment primary key company_name varchar(50), category_1 varchar(50) not null, category_2 varchar(50) not null, category_3 varchar(50) not null) insert company values ('apple', 'mobile', 'pc', 'gadget');

how can create query returns:

1, 'apple', 'mobile' 2, 'apple', 'pc' 3, 'apple', 'gadget'

you can utilize union :

select id, company_name, category_1 company union select id + 1, company_name, category_2 company union select id + 2, company_name, category_3 company

sqlfiddle

mysql sql

Comments

Popular posts from this blog

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -