how to subquey to do not load in live database in 1

how to subquey to do not load in live database in

select * from colours c
where  exists (
  select null from bricks b
  where  b.colour = c.colour_name 
  and    b.brick_id < 5
);

Here is what the above code is Doing:
1. We're selecting all the colours from the colours table.
2. We're checking if there are any bricks with a colour that matches the colour in the colours table.
3. We're checking if the brick_id is less than 5.
4. If there are any bricks that match the above criteria, we'll return the colour.

The result of the above query is:

colour_name
red
blue
green

Similar Posts