Mysql - Returning some records only if grouped

Asked

Viewed 89 times

1

I have a simple form system that records 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 started to happen after, last week, the server’s hard drives burned down. We were able to recover the Databases, but you came back with this problem.

An example of what happens:

Suppose I log it through 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 one SELECT in the bank using the ID of the specific provision, the is not brought, even though he is in the bank:

select * from prestacoes where prestacao_id = 11;

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

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

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

We suspect corrupted data, but it still doesn’t make sense, and the approval database has been having the same problem for a week. Before that, it was perfect.

  • 2

    I’ve never been through a situation like this, but maybe one solution is to migrate the data to another table (if the problem is just this tambela) or to another database, if other tables present the same problem.

  • How did you get the Dbs back? If I was going to kick, some conversion was done. Also check the type of the ID column.

  • We can try to help find the mistake, but the easiest way (the step I would try) is what Kadu said.

  • Then a dump was made. Finally, a Mysql Check was made and the answer is that it was all right. But still suspect that it is corrupted.

1 answer

1

What may be occurring may be both problems in your mysql, or computer schema problem, or a corrupted data problem in your database.

You can try to repair all the tables in your bank using the instruction 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: https://dev.mysql.com/doc/refman/5.1/en/repair-table.html

Browser other questions tagged

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