All Products
Search
Document Center

Simple Log Service:EXISTS clause

Last Updated:Jun 16, 2026

The EXISTS clause evaluates to TRUE if the specified subquery returns one or more rows, causing the outer SQL statement to execute.

Syntax

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

Parameters

Parameter

Description

subquery

The subquery is a SELECT statement.

Example

The following statement retrieves consumer group information when the read/write latency in a Logstore exceeds 1000.

  • Query and analysis 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
      )
  • The query and analysis result contains the consumer_group column. An example value is sls-ml-ag****ea76a483d4 (partially masked).