Separate data in table

Asked

Viewed 68 times

0

I would like to make a table separated by "seasons". Example:

Tabela estatisticas:
Temporada 1:
    ID | JOGADOR | PTS | AST |
    0  | Leonard | 12  | 7   |
    1  | Pedro   | 10  | 5   |
    Temporada 2:
    ID | JOGADOR | PTS | AST |
    0  | Leonard | 08  | 02  |
    1  | Pedro   | 09  | 03  |

Would you like it to be just a table, is that possible? If yes how can I do?

  • If the answer is right, please do not forget to mark as correct.

1 answer

1


Just add an extra column, huh? How would it look:

ALTER TABLE estatisticas ADD COLUMN 'temporada' INT(1) NOT NULL FIRST;

And when you go to select:

SELECT * FROM estatisticas ORDER BY temporada ASC;
  • I could add two equal players with different seasons?

  • Yes, but neither player name nor ID can be unique.

  • The same would be you have a table only for the players and another for the statistics, hence you would make a foreign key to the player ID.

  • I have a table only for players, as I would do it?

  • You can show me your tables?

  • table players: http://i.imgur.com/Iof2mvr.png and table Stats: http://i.imgur.com/Drdnzdx.png

  • In your case, the way I did in the answer fits well.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.