0

I want to solve a query challenge: print out all the names of the cities that do not start with a vowel. I used the following condition that was meant only for lower vowels but the MySQL engine was working even for upper case vowels too. Why is that?

Click here to get the sample input.

This is my solution:

select distinct city from station where left(city, 1) not in ('a','e','i','o','u');

I checked the data, there are cities like Arlington that start with an uppercase vowel but still is getting filtered out by the where clause that only concerns the lowercase vowels.

Aviral Srivastava
  • 4,058
  • 8
  • 29
  • 81
  • 2
    The default for MySQL is case-insensitivity. You should learn about collations and `binary`. – Gordon Linoff Aug 27 '20 at 22:16
  • You need to check your MySQL table and column Collations and Character Sets are Case Sensitive , ie, they end in `_cs` (`whatever_cs`, `latin1_general_cs`, etc.) – Martin Aug 27 '20 at 22:27

0 Answers0