sqlsqlitesubquerycorrelated-subquery

Does SQLite support ALL and ANY keywords?


Does SQLite support ALL and ANY keywords?

I keep facing syntax error while using them.

SELECT name, price
FROM products
WHERE price > ALL (
    SELECT price FROM products WHERE category = 'Electronics'
    );`

I can get what I want using a different approach. I want to know can I use ALL or ANY.

I tried using ALL to get name and price of the products that have a higher price than all products with category 'Electronics'.


Solution

  • SQLite does not directly support the ALL and ANY keywords. While SQLite does have an ALL keyword, it's used in a different context, specifically for selecting all rows from a table. It's not used in comparison operations like in other SQL dialects.

    you can achieve similar functionality like you used (>).

      SELECT * FROM table1
        WHERE column1 > (SELECT MAX(column1) FROM table2);