Issue with simple query

Viewed 36

I am having an issue with this simple query. I have to list all clients who didn't rent any movie from before 2015 Do I use Join for this or just a simple WHERE statement?

table clients:

customer_id,
name

table rentals:

customer_id, 
rental_date

Also, if my movie table contains description, title. How can I make a query to select both of them?

I can only do it like this

SELECT * from movies
WHERE description = 'something' && title ='something' 

I know this && is wrong, but how can I also add the title to it?

1 Answers

I'd use a not exists condition:

SELECT *
FROM   clients c
WHERE  NOT EXISTS (SELECT *
                   FROM   rentals r
                   WHERE  c.customer_id = r.customer_id AND
                          rental_date < DATE '2015-01-01'
Related