Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6104797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:52:59+00:00 2026-05-23T13:52:59+00:00

I am either getting old or the queries that I need to write are

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:53:00+00:00Added an answer on May 23, 2026 at 1:53 pm

    I’d probably use a UNION.

    SELECT `date`
       FROM `tasks` WHERE `user_id`=1
    UNION
    SELECT `t1`.`date`
       FROM `tasks` `t1`
       INNER JOIN `urls` `u1` ON `u1`.`id` = `t1`.`url_id`
       WHERE `u1`.user_id`=1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I notice that I am getting very poor performance for either or both inserts
I would like to either prevent or handle a StackOverflowException that I am getting
Trying to install symfony2 and I get the following message You need to enable
So situation is following : We have some very old product, that has dozen
I just installed the plugin for Paperclip and I am getting the following error
I'm using a new work computer that has an old sdk, Java 1.3.1, on
Disclaimer: this is needed for an old and ugly codebase that I'd much rather
I've seen, here and elsewhere, many questions that, to get input data, use something
I'm dealing with some old @ss legacy code that was written 3 or 4
Hey all, this will contain a few questions since I don't seem to really

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.