0

So I have a SQL query that returns a name and a id per row. The problem is that the name values, some are upper-cased and others are lower-cased. The query in question is:

SELECT DISTINCT ttd.name, ttd.tid
FROM taxonomy_term_data ttd
INNER JOIN field_data_field_xxxxxx_paraules_clau fdfspc ON ttd.tid = fdfspc.field_xxxxxx_paraules_clau_tid
ORDER BY ttd.name

the result is something like:

alfred | 1
ALBERT | 2
MARIA  | 3
Sam    | 4

What I want is a WHERE clause to only get the rows with upper-cased name like:

WHERE ttd.name IS UPPERCASED

I have been searching on internet, but I only get results about capitalize or uppercased text.

stackFan
  • 1,528
  • 15
  • 22
Albert Lazaro de Lara
  • 2,540
  • 6
  • 26
  • 41
  • 1
    Possible duplicate of [How to check for uppercase letters in MySQL?](https://stackoverflow.com/questions/16558967/how-to-check-for-uppercase-letters-in-mysql) – Robert H Feb 27 '18 at 16:29
  • `WHERE ttd.name > 'A'` might help regex should work even better `WHERE ttd.name REGEXP '^[A-Z]+'` – Raymond Nijland Feb 27 '18 at 16:30
  • Possible duplicate of [Select ALL fields that contains only UPPERCASE letters](https://stackoverflow.com/questions/3836825/select-all-fields-that-contains-only-uppercase-letters) – isaace Feb 27 '18 at 16:31
  • There are some results that are Capitalized (first letter upercased), so the Raymond solution doesn't work – Albert Lazaro de Lara Feb 27 '18 at 16:34

1 Answers1

0

This can be done with the BINARY comparison and UPPER() in mysql

WHERE ttd.name = BINARY UPPER(ttd.name)

source : How to find all upper case strings in a MySQL table?

louffi
  • 215
  • 5
  • 19