So I have a table of "Articles" that has a foreign key of "category_id".
Articles
| id | title | pub_date | category_id |
-----------------------------------
| 0 | abc | 23423443 | 1 |
| 1 | def | 23423423 | 2 |
| 2 | ghi | 24234234 | 1 |
| 3 | jkl | 23423424 | 3 |
| 4 | mop | 23432435 | 2 |
Categories
| id | title |
----------------
| 1 | News |
| 2 | Feature |
| 3 | Review |
I have the title of a category.
I would like to, in one query, ascertain the id of said category and use it to return articles where the category_id = id and publish date is less than the current date time.
Is this possible?
I am using Postgres but I am looking at this from an academic standpoint so answers in any SQL dialect would be fine as I am happy to do the translation myself for the education.