-4

I have the following table:

enter image description here

I want like this:

enter image description here

Thanks!

Barbora
  • 921
  • 1
  • 6
  • 11
chen
  • 1
  • 2

1 Answers1

-1

I don't recommend this process because it is extremely messy, but if it helps, more power to you, I guess. Also, make sure that when you post a question, you include the code that the question is referring to. It helps other users a lot more and makes them much more willing to help!

Because MySQL will not let you put in repeat CHAR or VARCHAR columns, I suggest you either uniquely name the columns based on why they're separated this way, or make unique tables.

Unique Column Names:

CREATE TABLE 'tableName' (
id INT NOT NULL,
time1 TIME NOT NULL,          //Just continue naming your columns in a different way
action1 CHAR(6) NOT NULL, 
station1 VARCHAR NOT NULL,
PRIMARY KEY(primaryKey)       //Use this to uniquely identify you table by a distinct 
);                            //variable (probably id)

To make unique tables, just repeat the table above over and over again with a different Table Name. To connect all your tables together, use a foreign key. This key's variable needs to have entries that exist in all tables to have all table data connected. Read more about it here: Foreign Keys and How to Use Them

Good Luck!

hpotter_otter
  • 61
  • 1
  • 5
  • Not downvoting, but this question does not deserve an answer. It meets nearly all criteria that make it a bad question, just as bruno desthuilliers mentioned in his comment. – shmee Aug 01 '18 at 13:08
  • @shmee I realize that, but everyone deserves a little kindness when they begin on here. Pointing them in the right direction does a lot better than just saying it's a bad question and moving on. :) – hpotter_otter Aug 01 '18 at 13:09
  • 1
    Better for the OP, not the website. Rewarding people who break the rules encourages more people to do the same. – takendarkk Aug 01 '18 at 13:15
  • @csmckelvey 1, thanks for downvoting. 2, if you read through my whole answer, you will see that I did tell chen to write questions correctly. I am not rewarding for breaking a rule. I am trying to discourage what they are doing and giving them a reason why, which encourages them to do it properly. – hpotter_otter Aug 01 '18 at 13:21
  • For that individual: yes. For the community: not so much ;) – shmee Aug 01 '18 at 13:22
  • Anyway, thank you all, I'll make a good improvement next time – chen Aug 02 '18 at 01:30