Search code examples
sqlsqliteselectany

SQLite syntax for operator “ANY”


I'm trying execute this query in SQLite:

SELECT *
FROM customers 
WHERE rating = ANY
      (SELECT rating
       FROM customers
       WHERE city = 'Rome');

But received this error:

Query Error: near "SELECT": syntax error Unable to execute statement

If I replace rating = ANY to rating IN, everything works fine.

Can someone show me how ANY statement works in SQLite and what I am doing wrong?


Solution

  • AFAIK, SQLite doesn't have an ANY operator. You could, however, use the IN operator to get the required functionality:

    SELECT *
    FROM   customers 
    WHERE  rating IN -- Here!
           (SELECT rating
            FROM   customers
            WHERE  city = 'Rome');