検索

11.4.14. 関係比較について

download PDF
比較には比較演算子 ( =, >, >=, <, <=, <>]>) の1 つが関与します。また、HQL は <![CDATA[<> の比較演算子の同義として != を定義します。演算対象は同じ型でなければなりません。

例11.17 関係比較の例

// numeric comparison
select c
from Customer c
where c.chiefExecutive.age < 30

// string comparison
select c
from Customer c
where c.name = 'Acme'

// datetime comparison
select c
from Customer c
where c.inceptionDate < {d '2000-01-01'}

// enum comparison
select c
from Customer c
where c.chiefExecutive.gender = com.acme.Gender.MALE

// boolean comparison
select c
from Customer c
where c.sendEmail = true

// entity type comparison
select p
from Payment p
where type(p) = WireTransferPayment

// entity value comparison
select c
from Customer c
where c.chiefExecutive = c.chiefTechnologist

比較には、サブクエリ限定子である ALLANYSOME も関与します。SOMEANY は同義です。
サブクエリの結果にあるすべての値に対して比較が true である場合、ALL 限定子は true に解決されます。サブクエリの結果が空の場合は false に解決されます。

例11.18 ALL サブクエリ比較限定子の例

// select all players that scored at least 3 points
// in every game.
select p
from Player p
where 3 > all (
   select spg.points
   from StatsPerGame spg
   where spg.player = p
)
サブクエリの結果にある値の一部 (最低でも 1 つ) に対して比較が true の場合、ANY または SOME 限定子は true に解決されます。サブクエリの結果が空である場合、false に解決されます。
Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

© 2024 Red Hat, Inc.