Reputation: 2584
I have a danish website developed in PHP
. I am using mysqli
.
I have the words like Daugård and Århus in database field called tags.
I want this both values as result when I run a query like below.
Query : select * from table_name where tags like '%år%';
Expected result : Daugård and Århus both
Actual result : Daugård
Right now its performing case-sensitive match and returning only Daugård word. I tried changing charset to utf8 dynamically by function set_charset('utf8'), but it didn't work.
Collation for the 'tags' field is 'utf8_general_ci'
, table collation is 'utf8_general_ci'
and my database collation is 'latin1_swedish_ci'
.
Help me how can I achieve this?
Upvotes: 0
Views: 166
Reputation: 11
To avoid the collation issue, use a case conversion function on "tags" before comparison:
select * from table_name where lcase(tags) like '%år%';
I might be missing something as MySQL isn't that familiar to me. I know the function LOWER(tags) does the job in Oracle as long as the pattern searched for also is in lower case.
Upvotes: 1