Поиск с учетом регистра MySQL utf8_bin поля

Для меня я использовал Android Studio, когда столкнулся с этой проблемой, я использовал Google Admob и Analytics внешние SDK.

Теперь они отправляют их вместе с Kitkat SDK, который вызвал конфликт, и было решено открыть файл project.iml и удалить следующие строки:

<orderEntry type="module-library">
  <library>
    <CLASSES>
      <root url="jar://$USER_HOME$/Downloads/Ads/lib/amazon-ads-4.0.9.jar!/" />
    </CLASSES>
    <JAVADOC />
    <SOURCES />
  </library>
</orderEntry>
<orderEntry type="module-library">
  <library>
    <CLASSES>
      <root url="jar://$USER_HOME$/Downloads/Folx/application/GoogleAdMobAdsSdk-6.2.1/Add-ons/googleanalyticsandroid/libGoogleAnalyticsV2.jar!/" />
    </CLASSES>
    <JAVADOC />
    <SOURCES />
  </library>
</orderEntry>

Надеюсь, это поможет, позаботьтесь ..

18
задан 6 May 2013 в 11:25
поделиться

2 ответа

A string in MySQL has a character set and a collation. Utf8 is the character set, and utf8_bin is one of its collations. To compare your string literal to an utf8 column, convert it to utf8 by prefixing it with the _charset notation:

_utf8 'Something'

Now a collation is only valid for some character sets. The case-sensitive collation for utf8 appears to be utf8_bin, which you can specify like:

_utf8 'Something' collate utf8_bin

With these conversions, the query should work:

select * from page where pageTitle = _utf8 'Something' collate utf8_bin

The _charset prefix works with string literals. To change the character set of a field, there is CONVERT ... USING. This is useful when you'd like to convert the pageTitle field to another character set, as in:

select * from page 
where convert(pageTitle using latin1) collate latin1_general_cs = 'Something'

To see the character and collation for a column named 'col' in a table called 'TAB', try:

select distinct collation(col), charset(col) from TAB

A list of all character sets and collations can be found with:

show character set
show collation

And all valid collations for utf8 can be found with:

show collation where charset = 'utf8'
40
ответ дан 30 November 2019 в 06:46
поделиться

Могу я спросить, почему вам нужно явно изменять параметры сортировки, когда вы выполняете SELECT? Почему бы просто не сопоставить так, как вы хотите получать записи при сортировке?

Проблема, с которой вы сталкиваетесь с учетом регистра при поиске, заключается в том, что у вас есть двоичное сопоставление. Вместо этого попробуйте использовать общую сортировку. Дополнительные сведения о чувствительности к регистру и сопоставлениях см. Здесь: Чувствительность к регистру при поиске строки

1
ответ дан 30 November 2019 в 06:46
поделиться
Другие вопросы по тегам:

Похожие вопросы: