I have a table that I need a MYSQL Select statement so I can find the corrupt data and manually fix it.
Sample table
TABLE_A id | type | value1 | value2 1 | 10 | 123 | 987 2 | 10 | 123 | 987 3 | 10 | 123 | 789 4 | 20 | 123 | 987 5 | 20 | 456 | 987 6 | 30 | 123 | null 7 | 30 | 123 | null 8 | 40 | 123 | 987
I need a select statement that will list records that if they have the same “type” and value1 is not the same and/or value2 not the same.
For Example
-
ID 1,2,3 – will be displayed because value2 is different in id 3 and they have the same “type”
-
ID 4,5 will be displayed because value1 is different and they have the same “type”
-
ID 6,7 will NOT be displayed because value1 and value2 are the same for the same “type”
-
ID 8 will NOT be displayed because there is only one with this type.
I have been trying to get my head around this for days and need some help. Thanks
1 Answer