mysql - merging two SELECT queries -


i either getting old or queries need write getting more , more complicated. following query tasks associated user.

"select `date`     `tasks`    `user_id`= 1;" 

the tasks table (id, date, user_id, url_id);

now, need records url_id associates user trough the

`urls` table (`id`, `user_id`) 

the standalone query this:

"select `t1`.`data`     `tasks` `t1`     join `urls` `u1` on `u1`.`id` = `t1`.`url_id`    `u1`.user_id` = 1;" 

though, possible merge these 2 queries single query? logic says should be, though don't see how actual join.

i'd use union.

select `date`    `tasks` `user_id`=1 union select `t1`.`date`    `tasks` `t1`    inner join `urls` `u1` on `u1`.`id` = `t1`.`url_id`    `u1`.user_id`=1; 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -