0
0

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 3 years have passed since last update.

LIKE や NOT LIKE はNULL まで判定してしてしまう話。

Posted at

例えば

favorite_table

name food
tanaka 野菜ラーメン
satou ちゃんぽん
ikeda みそラーメン
numata やさい
inoue

ラーメン以外のnameを取得したい時に

SELECT *
FROM favorite
WHERE food NOT LIKE 'ラーメン';

みたいにしてしまうと
inoueさんが出てこなくなってしまう。

今の所

WHERE food IS NULL OR food NOT LIKE 

ってやるとうまくいくみたいだけどもっといい書き方ないかな。

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?