.. _EXISTS条件:
EXISTS条件
~~~~~~~~~~~~~~

EXISTS 条件用于测试子查询中的行是否存在。

.. code::

  EXISTS (subquery)

.. figure:: images/exists-exists_condition.png
 :align: center

下表显示了 EXISTS 条件。

.. list-table:: EXISTS条件
   :widths: 25 35 40
   :header-rows: 1

   * - 条件类型
     - 操作
     - 例子
   * - EXISTS 
     - 如果子查询至少返回一行，则为 TRUE。
     - SELECT department_id
       FROM departments d
       WHERE EXISTS
       (SELECT * FROM employees e
       WHERE d.department_id 
       = e.department_id)
       ORDER BY department_id;
  

