PostgreSQL
PostgreSQL EXISTS
Test whether a subquery returns at least one row.
Use EXISTS
SELECT p.name
FROM products AS p
WHERE EXISTS (
SELECT 1
FROM featured_products AS f
WHERE f.product_name = p.name
);EXISTS is true as soon as the subquery finds a row. The selected value inside the subquery is not important.
Further Reading
Continue learning with these related tutorials:
- PostgreSQL Introduction
- PostgreSQL pgAdmin 4
- PostgreSQL Create Table
- PostgreSQL Insert Data
- PostgreSQL Select Data
- PostgreSQL ADD COLUMN
- PostgreSQL UPDATE
- PostgreSQL ALTER COLUMN
- PostgreSQL DROP COLUMN
- PostgreSQL DELETE
- PostgreSQL DROP TABLE
- PostgreSQL Operators
- PostgreSQL SELECT
- PostgreSQL SELECT DISTINCT
- PostgreSQL WHERE
- PostgreSQL ORDER BY
- PostgreSQL LIMIT
- PostgreSQL MIN and MAX
- PostgreSQL COUNT
- PostgreSQL SUM
- PostgreSQL AVG
- PostgreSQL LIKE
- PostgreSQL IN
- PostgreSQL BETWEEN
- PostgreSQL AS
- PostgreSQL Joins
- PostgreSQL INNER JOIN
- PostgreSQL LEFT JOIN
- PostgreSQL RIGHT JOIN
- PostgreSQL FULL JOIN
- PostgreSQL CROSS JOIN
- PostgreSQL UNION
- PostgreSQL GROUP BY
- PostgreSQL HAVING
- PostgreSQL EXISTS
- PostgreSQL ANY
- PostgreSQL ALL
- PostgreSQL CASE
Continue learning
