タグ

ブックマーク / qiita.com/accakr (1)

  • MySQLのNULLと空値でハマる - Qiita

    たとえば MySQL 5.6 hoge varchar(2) NULL可 100件のレコードのうち、10件がNULL、90件が"AA" select count(1) from tablename where hoge is null : 10件 → わかる select count(1) from tablename where hoge is not null : 90件 → わかる select count(1) from tablename where hoge = 'AA' : 90件 → わかる select count(1) from tablename where hoge = '' : 0件 → わかる select count(1) from tablename where hoge != '' : 90件 → !!!! 言い訳 ''自体がクソコードなわけですが、= '

    MySQLのNULLと空値でハマる - Qiita
    kahki
    kahki 2019/11/15
  • 1