MySQL Forums
Forum List  »  Newbie

Re: Help using MySQL reformatting data
Posted by: Phillip Ward
Date: October 05, 2023 12:27AM

Good catch.
My query should have selected the column name/header and not the actual value.

Take two:

insert 
into table2 ( state, city, store, sku )
          select state, city, store, 'chocolate_sku' as sku from table1 where chocolate_sku = 1
union all select state, city, store, 'strawberry_sku'       from table1 where strawberry_sku = 1
union all select state, city, store, 'cookiescream_sku'     from table1 where cookiescream_sku = 1

Again, the trick is in creating this query from the given input.

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
Re: Help using MySQL reformatting data
October 05, 2023 12:27AM


Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.