Question: I´m trying to build a query using a subquery in my WHERE condition, and when the subquery table is empty, I actually want to apply no filters to my query, and get all entries.

How can I achieve what I want?

This is my query:

```
SELECT 
m.Material,
p.Plant
FROM dbo.AllPlants AS p
JOIN dbo.AllMaterials AS m
ON p.MaterialID = m.MaterialID
WHERE p.Plant IN ( SELECT Plant FROM dbo.MyFavoritePlants);

```

If I have no Favorite Plants, I want All Plants!

Answer: 
You could add second condition to handle that scenario:

```
SELECT 
m.Material,
p.Plant
FROM dbo.AllPlants AS p
JOIN dbo.AllMaterials AS m
ON p.MaterialID = m.MaterialID
WHERE p.Plant IN (SELECT Plant FROM dbo.MyFavoritePlants)
   OR NOT EXISTS (SELECT 1 FROM dbo.MyFavoritePlants)

```
I don't have enough reputation yet to comment but this might work

```
SELECT 
m.Material,
p.Plant
FROM dbo.AllPlants AS p
JOIN dbo.AllMaterials AS m ON p.MaterialID = m.MaterialID
LEFT JOIN dbo.MyFavoritePlants FP ON FP.Plant = P.Plant

```