MySQL - Returning some records only if grouped

1

I have a simple form system that registers in the bank the amount of daily benefits of a person in the company.

The database does not return this data in most cases. The problem began to happen after last week's server's HD's burned out. We were able to recover the databases, but came back with this problem.

An example of what happens:

Suppose I log on to the system:

ID: 11 | Prestação: Atendimento | Quantidade: 10| 

ID: 12 | Prestação: Palestra    | Quantidade: 5 |

ID: 13 | Prestação: Audiências  | Quantidade: 2 | 

If I make a SELECT in the bank using ID of the specific installment, the registry is not brought even though it is in the bank :

select * from prestacoes where prestacao_id = 11;

If I make another SELECT using IN() , the record that did not return previously (11), returns with another:

select * from prestacoes where prestacao_id in(11,12)

Worst of all is that this happens with just a few specific records. Suppose the records with the problem are ID's 11 and 13, the 12 returns normally.

We suspect corrupted data but it still does not make sense, and the homologation database has had the same problem for a week. Before that, it was perfect.

    
asked by anonymous 20.07.2015 / 16:34

1 answer

1

What may be occurring can be both problems in your mysql, and problem in the information_schema, as a problem of corrupted data in your database.

You can try to repair all the tables in your bank using the statement below:


SELECT CONCAT('repair table ', table_name, ';') 
FROM information_schema.tables WHERE table_schema = 'NOMEDOSEUBANCO';
concat('repair table ', table_name, ';');

Or try to repair a single table, like this:

repair table SUA_TABELA;  

And see if that solves your problem. For more information, see: link

    
20.07.2015 / 23:02