All Products
Search
Document Center

Simple Log Service:EXISTS clause

Last Updated:Mar 26, 2026

The EXISTS clause tests for the existence of rows in a subquery. If the subquery returns at least one row, EXISTS evaluates to true and the outer SQL statement executes.

Syntax

SELECT...FROM...WHERE EXISTS (subquery)

Parameters

Parameter

Description

subquery

An arbitrary SELECT statement.

Example

Check whether the read/write latency of a Logstore is greater than 1000. If so, the query returns the consumer group information.

  • Query statement

    * |
    SELECT
      consumer_group
    FROM  "internal-diagnostic_log"
    WHERE
      EXISTS (
        SELECT
         Latency
        FROM     internal-operation_log
        WHERE
          "internal-diagnostic_log".Logstore = "internal-operation_log".Logstore and latency >1000
      )
  • ResultsEXISTS