suchen

Heim  >  Fragen und Antworten  >  Hauptteil

Ungültige Eingabe: WITH ist in diesem Kontext keine gültige Syntax

Ich habe also eine ähnliche Anfrage

WITH customers_in_usa AS (
        SELECT 
           customerName, state
        FROM
           customers
        WHERE
           country = 'USA'
    ) SELECT 
        customerName
    FROM
        customers_in_usa
    WHERE
        state = 'CA'
    ORDER BY customerName;

Aber beim Schreiben habe ich einen Fehler gefunden: „WITH Invalid input at this position“ error_picture. Können Sie mir helfen zu verstehen, was mit diesem Code nicht stimmt?

P粉124070451P粉124070451479 Tage vor518

Antworte allen(1)Ich werde antworten

  • P粉851401475

    P粉8514014752023-10-24 00:39:02

    WITHcustomers_in_usaAS 目前是无效的 MySQL 代码。 MySQL 将来将在 MySQL 版本 8 中支持 CTE。

    您可以重写 SQL 代码,这应该会产生相同的结果。

    SELECT 
        customerName
      , state
    FROM 
       customers 
    WHERE
       country = 'USA'
     AND
       state = 'CA'
    ORDER BY
       customerName

    Antwort
    0
  • StornierenAntwort