I am either getting old or the queries that I need to write are getting more and more complicated. The following query will get all the tasks associated with the user.
"SELECT `date`
FROM `tasks`
WHERE `user_id`= 1;"
The tasks table is (id, date, user_id, url_id);
Now, I need to get as well records that url_id associates with the user trough the
`urls` table (`id`, `user_id`)
The standalone query would look like this:
"SELECT `t1`.`data`
FROM `tasks` `t1`
JOIN `urls` `u1` ON `u1`.`id` = `t1`.`url_id`
WHERE `u1`.user_id` = 1;"
Though, is it possible to merge these two queries into a single query? My logic says it should be, though I don’t see how to do the actual JOIN.
I’d probably use a UNION.