SQLite syntax for operator “ANY”

Aksios picture Aksios · Feb 11, 2016 · Viewed 7.1k times · Source

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?

Answer

Mureinik picture Mureinik · Feb 11, 2016

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');