Question

Assume I have city field with the given values:

  1. New York
  2. Toronto
  3. xxxxxxx
  4. ------

I would like to run a sql query that return cities that have three or more consecutive characters that is row #3 and row #4

characters might be:

  • spaces
  • tabs
  • non-breaking spaces

My rough attempt; I didn't test the code yet:

SELECT * FROM table WHERE REGEXP_LIKE(city,'[[:space:|x|-]]+')

Thanks

Was it helpful?

Solution

This will work for the sample data, only checks the first 3 characters.

SELECT * FROM cities
WHERE SUBSTR(Name,1,1) = SUBSTR(Name,2,1)
AND SUBSTR(Name,2,1) = SUBSTR(Name,3,1);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top