7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【MySQL】ひらがなとカタカナ(全角、半角)の検索

Last updated at Posted at 2014-02-12

あるカラムをひらがなとカタカナ(全角、半角)で検索する場合、collate utf8_unicode_ciを使うと便利。
※utf8を使用していることが前提。

設定
alter table table_name collate utf8_unicode_ci;
sql
-- これで「%すずき%」「%スズキ%」「%スズキ%」が検索対象に入る。
select * from keiyaku_lists where user collate utf8_unicode_ci like '%すずき%';

上記をorで書くと以下のようになる。

上記をorを使用して書いたsql
select * from keiyaku_lists where user like '%すずき%' or user like '%スズキ%' or user like '%スズキ%';

7
8
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?