Thanks to some help on this site, I’ve written a query to find any rows WHERE ‘first’ or ‘last’ are not capitalized. Each condition works fine on its own, but when combined into a single query with OR, then I no longer detect non-capitalized entries in the ‘first’ column – only in the ‘last’ column. Where am I going wrong? Thanks.
SELECT first,last FROM main WHERE
CONCAT( UPPER( SUBSTRING(first,1,1) ), SUBSTRING(first FROM 2) ) != first
OR
CONCAT( UPPER( SUBSTRING(last,1,1) ), SUBSTRING(last FROM 2) ) != last
COLLATE latin1_general_cs
You need the COLLATE on both conditions:
Or, simplifying the query per the suggestion in the comments above: