1

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
  • 19,717
  • 37
  • 107
  • 164

3 Answers3

2

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
  • 157,677
  • 23
  • 242
  • 245
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,242,037
  • 58
  • 646
  • 786
  • 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,435
  • 11
  • 25