Imagine that you have a field with data like this (each line represents the data in that field for different rows):
28746: Porto Alegre
28302: Osasco
28797: Praia Grande
But sometimes there is more than one number in the field:
26755: Floriano Peixoto,26754: Floriano 25582: Bela Vista
25579: Bela Vista 25581: Bela Vista De Goiás,26867: Goiás
I know this data it’s not normalized, but that’s not the issue I want to solve.
I was wondering if it’s possible to make a query that shows only the rows that have more than one number in that field.
Any suggestions on how to achieve that?
UPDATE
From Dark_a answer I tried this:
SELECT data_c1
FROM test_data
WHERE INSTR(data_c1,':',1,2) <> 0;
But it seems that INSTR only accepts to arguments:
http://dev.mysql.com/doc/refman/5.5/en/string-functions.html
However if I use this other query:
SELECT data_c1
FROM test_data
WHERE INSTR(data_c1,',') <> 0;
It seems to work fine, because the data in fields with more than one number, it’s separeted by a comma.
You can try this:
If comma is used in text. if not then is better to check for comma: