All Products
Search
Document Center

Simple Log Service:INTERSECT clause

Last Updated:Mar 25, 2026

The INTERSECT clause is used to combine the result sets of two SELECT statements and return only rows that are common to the result sets of the two SELECT statements. This topic describes the syntax of the INTERSECT clause. This topic also provides examples on how to use the INTERSECT clause.

Syntax

SELECT key1... FROM logstore1
INTERSECT
SELECT key2... FROM logstore2
Important
  • Each SELECT statement must return the same number of columns. The corresponding columns must be in the same order and have the same data type.

  • The INTERSECT clause removes duplicate rows from the final result set.

Parameters

Parameter

Description

key

A field name, a column name, or an expression.

You can specify different values for key1 and key2, but you must specify the same data types for them.

Logstore

The name of the Logstore.

Examples

A Logstore named internal-diagnostic_log stores important logs, including logs on consumption latency, alerts, and data collection for each Logstore. Another Logstore named internal-operation_log stores detailed logs, including operational logs for all resources within a Project. You can use the INTERSECT clause to find the Logstores that generate both detailed and important logs.

  • Query and analysis statement

    * |
    SELECT
      logstore
    FROM  internal-operation_log
    INTERSECT
    SELECT
      logstore
    FROM  internal-diagnostic_log
  • Query and analysis resultsINTERSECT