0

I have a table with a column name. The values in this column can be capitalized or not (e.g. both "adam" and "Adam"). How can I select only values that are capitalized (start with an uppercase letter)?

Chin
  • 18,166
  • 35
  • 100
  • 154

3 Answers3

1

If you're using SQLite3, you can employ the REGEXP expression

WHERE name REGEXP '^[A-Z]'

There's some good information in this answer regarding installation ~ https://stackoverflow.com/a/8338515/283366

Phil
  • 141,914
  • 21
  • 225
  • 223
0

You can be explicit with collate binary and a comparison:

where name collate binary = 'Adam' collate binary

However, binary is often the default so it is probably not necessary.

If you mean any capitalized letter, then:

where substr(name, 1, 1) collate binary = 'A' collate binary
Gordon Linoff
  • 1,198,228
  • 53
  • 572
  • 709
  • 1
    Whilst required, I don't think this answers the question of *"How can I select only values that are capitalized (start with an uppercase letter)?"* – Phil Jul 27 '17 at 00:16
  • @Phil . . . I see what you mean. Your interpretation makes more sense. – Gordon Linoff Jul 27 '17 at 00:17
  • 1
    I want to search all names, and the names in the column don't just start with A, it can be any letter. – Chin Jul 27 '17 at 00:19
0

An elegant way of doing it using REGEX:

SELECT * 
FROM 'your_table'
WHERE 'field' REGEXP BINARY '^[A-Z]'
Sletheren
  • 2,287
  • 7
  • 23