PostgreSQL には、大文字と小文字を区別しない単純な比較機能はありますか?
交換したいもの:
SELECT id, user_name
FROM users
WHERE lower(email) IN (lower('[email protected]'), lower('[email protected]'));
たとえば次のようになります:
SELECT id, user_name
FROM users
WHERE email IGNORE_CASE_IN ('[email protected]', '[email protected]');
and演算子like
はilike
単一の値 (例) では機能しますが、セットでは機能しません。like '[email protected]'
ベストアンサー1
select *
where email ilike '[email protected]'
ilike
は、大文字と小文字を区別しませlike
ん。エスケープ文字には、replace()
where email ilike replace(replace(replace($1, '~', '~~'), '%', '~%'), '_', '~_') escape '~'
または、テキストをエスケープする関数を作成することもできます。テキストの配列の場合は、
where email ilike any(array['[email protected]', '[email protected]'])