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 9233623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:35:55+00:00 2026-06-18T06:35:55+00:00

I know the question seems duplicate, but I don’t know how to ask it

  • 0

I know the question seems duplicate, but I don’t know how to ask it differently.

I have two very simple tables in MySQL database, The first is table Users

id,   user_id
 1       1
 2       3
 4       4

The second is table Friends

id,    user_id,    friend_id
 1        1             3
 2        1             4
 3        1             8

I dumped the data from CSV file that I would like to clean. I need to check if friend_id exists in table 1 as well. The first table has around 30000 rows, but the second table has around 30 million rows.

And I use this query to check



SELECT u.user_id, uf.friend_id as exists_friend_ids
FROM Users u, Friends uf
WHERE u.user_id = '1'
    and uf.friend_id IN (select user_id from eventify.Users)

However, my desired output would be this but as I cannot run the above query to actually give my test results I cannot continue.

user_id,   exists_friend_ids
    1            3
    1            4

You can see that 8 is not there, because it doesn’t exist in Users table. But as the second table has over 30 million records it’s just running forever on my computer. Am I doing it right or this is the only way to do it. Or should I learn Hadoop instead?

I have updated my query to use equal 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-06-18T06:35:57+00:00Added an answer on June 18, 2026 at 6:35 am

    Have you tried a LEFT JOIN query with a GROUP BY friend_id ? If a user doesn’t exist, it won’t add a line to the result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, I know this seems like a duplicate question, but don't think it is.
I know My question seems Like duplicated( duplicate )... But exceptionally I'm not trying
I know the question title seems like a duplicate, but I've been unable to
I know this question seems subjective but it's really pretty simple. As a long
I know this seems like a repeat question, but i've read all the others
It seems to be really stupid question, I know. But anyway. Lats say, I
This question might not seem very technical but, out of curiosity,I want to know
I know that that question may be seemed as a duplicate, but I haven't
I know there is an almost duplicate question, but the answer is not satisfactory
I know that this may be a duplicate question,but I could not find any

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.