1

1) select name from city where countrycode="JPN" ;

2) select name from city where countrycode='JPN' ;

3) select name from city where countrycode="jPn" ;

all the above queries are working in query 2 i am using single quotes and in 3 query i am using mixture of upper case and lowercase character . why it is producting correct output??.

Vishal
  • 18
  • 3
  • 2
    what dbms are you using? – m.antkowicz Mar 23 '17 at 17:43
  • Obviously both quotation marks are allowed in the syntax of your db server. And wether the comparison is case-sensitive or not depends on the _collation_ configured for your column, table or database. – René Vogt Mar 23 '17 at 17:43
  • SQL queries are typically case insensitive – imtheman Mar 23 '17 at 17:44
  • 1
    Possible duplicate of [How to do a case sensitive search in WHERE clause (I'm using SQL Server)?](http://stackoverflow.com/questions/1831105/how-to-do-a-case-sensitive-search-in-where-clause-im-using-sql-server) – imtheman Mar 23 '17 at 17:44

1 Answers1

2

I guess I misread the original question. Some database implementations are case insensitive are some aren't. Usually reserved keywords like SELECT, WHERE, etc.. are case-insensitive. It might be worth forcing to lower or uppercase for your WHERE clause.

Consider using LOWER or UPPER to force lower or upper case

SELECT name from city where LCASE(countrycode) = "jpn"

I haven't used it personally so it might be worth benchmarking for speed.

AlexG
  • 1,091
  • 7
  • 15