How to group comic book values?

Asked

Viewed 91 times

1

I am rephrasing this question more clearly. I have the following challenge; I have a BD that contains 16 fields of information, this BD keeps bets placed in a system, to later be able to process the result and payment of the customer’s ticket. In the administration part, ADM has an area where it is possible to place the results of the games that were made by the customer, when the customer makes a bet, is stored the name of the team, the type of bet, and the match. For example, have a game of Vasco and Flamengo, you bet that Vasco will make 2 goals in the second half, in BD I store this information as follows:

Name of the team: Vasco.

Type of bet: +2.

Clash: Vasco x Flamengo.

In the administrative part, ADM has to check all the games that are in BD, except that several customers make the same type of bet, IE, I will have in BD 15,20 repeated records, with the same Team name, even Type of bet and even Showdown.

The Administrator, makes the conference of the games, for a select, i print all BD records in one, select has 3 options, "won, lost, canceled". and by the ID of that confrontation log, I can update the result in the BD.

But the problem, is that it has many repeated results, and it becomes complicated for the administrator to put the same result in several equal games, example: Print do sistema com jogos repetidos

What I want, is to group these games, based on the same match, Wager and Wager condition, and the result that the administrator put in select, worth for all of the same group, without having to put the same result several times. In PHP I can group in the sql:

$conexao->prepare('SELECT time_apostado,tipojogo,tipoaposta,codigo  FROM bilhetes_temp WHERE codigo GROUP BY time_apostado,tipojogo,tipoaposta');

But I have no idea how to show only 1 result to the admin, and make the result of the select he puts, worth to all others who are equal.

I hope not to have been long in explaining, had not as I summarized such question rs. So someone give me an idea of how I group these results in the PHP or also in the JasvaScript?

  • complicated to understand... would have to reread 10 or 20 times and it takes a lot of time. be more objective and clear.. and also try to write in a more organized way, with a good grammar also helps others to read and interpret your text. I confess that I read the first words and already gave a mental confusion and from then on it was lazy to read the rest.. I imagine others feel the same.

1 answer

3


You say in the question that you know the GROUP BY function and that you know how to group by a value. You can use this function to group across three columns, thus removing duplicate results.

This can be done as follows:

SELECT Time, TipoDeJogo, DataDoJogo
FROM TABELA_JOGOS
GROUP BY Time, TipoDeJogo, DataDoJogo
ORDER BY Time, TipoDeJogo, DataDoJogo
  • 1

    Bruno, thank you very much, I tried something similar but it didn’t work, your way worked well.

Browser other questions tagged

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