I wonder if SQL LIKE is case sensitive?
The command LIKE
just makes comparison of string
as determined pattern passed. Who is responsible for the case (in)sensitive is the collation
.
It is possible to perform case insensitive search (if sensitive) using SQL LIKE ?
Yes, depending only on the collation configured.
If you search for a name with accentuation it is possible that it identifies that "Luis" has relationship with "Luis" and vice versa?
Yes, depending only on the collation configured.
In accordance with this answer about What is the difference between charset and collation in a database?, understand what is collation:
Collation
Collation is the term used to define the set of rules that the
server will use for sorting and comparing text, or
be, how the operators =, >, <, order by, etc.
For example, depending on the configured Collation, the system will
sort the'ö' character between the ːo' and ːp' characters, using another
collation, this character can be ordered in another position. Therefore
can give conflict when making queries that relate tables to
different collations. In addition, the collation also defines whether the
system will differentiate accented characters or if it will be case
sensitive, for example the collation Latin1_general_ci_as defines the
system should treat characters as case insensitive (CI) and
acentue sensitive (AS). Examples:
latin1_general_ci: No distinction between capital letters and
lowercase. Searching for "test", records such as "Test" or "TEST"
will be returned.
latin1_general_cs: Distinguishes capital letters and
lowercase. Searching for "test" will only return "test". Options
as "Test" and "TEST" will not be returned.
latin1_swedish_ci: Not
distinguishes between lower and upper case letters and no accented characters, and
with cedilla, that is, the record that contains the word "intuition" will be
returned when there is a search for the word "intúicao"
Depends on the DBMS. Which one you are using?
– Giuliana Bezerra
If it is Sqlserver for example this comparison depends on the Collation of the field, he who defined this type of comparison
– Jeferson Almeida
It is not the operator that differentiates between upper and lower case, it is the column itself as our friend Jeferson Almeida mentioned above.
– user60252
I updated the question and includes the Mysql tag, which is what I use.
– LP. Gonçalves
If the Collation is
*_ci
he is case insensitive, ie bothLuís
how muchluís
is the same. Now, accentuation is another story, which also depends on the Collation, if you are using theutf8_unicode_ci
will ignore the accents too. Possible related http://answall.com/questions/30329/qual-a-diff%C3%A7a-entre-charset-e-collation-em-database.– Inkeliz