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?

比較演算子 !=と<>は違うの?【初心者 SQL】

0
Posted at

SQLにおけるノットイコールの書き方

きっかけ

SQLの問題を解いていたのですが、「○○ではない」といった条件式を表せという問題に出会ったので、自分は以下で回答

(誤答)SELECT * FROM store WHERE NOT price = 2000;

テキスト的には
NOTを使うのは複雑な条件式の時だったり、LIKEを使った時などで、
単一の条件式を否定するときには!= または<>を使うのだそう。

なぜ、否定が2種類の表現がある?

じゃあ、否定は2種類あるのだけど、どうして?と疑問が出た。
調べると使い分けはなく、
”!=”は"<>"のエイリアスだそうで、高速にSQLの”!=”は”<>”に読み替えられるのだそう。

自分は<>で書いていこうと思います。

参考にした記事

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?