0

I can't to build this query it returns all rows from table. I want to select only this records where catid is between 1 and 20 and only these records from interval of 30days. Seperated both queries working.

- SELECT * FROM `movies` WHERE uploaded >= DATE_SUB(NOW()
- SELECT id FROM `movies` WHERE (catid BETWEEN 1 AND 20)

Whole query with subquery:

SELECT * FROM `movies` WHERE uploaded >= DATE_SUB(NOW(), INTERVAL 30 DAY) IN(SELECT id FROM `movies` WHERE (catid BETWEEN 1 AND 20))
0

1 Answer 1

4
SELECT * FROM `movies` 
WHERE uploaded >= DATE_SUB(NOW(), INTERVAL 30 DAY) 
AND catid BETWEEN 1 AND 20
Sign up to request clarification or add additional context in comments.

1 Comment

Works perfect therefore I don't need from subquery :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.