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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:23:14+00:00 2026-05-20T06:23:14+00:00

Hello all I am creating a report at work and for some reason am

  • 0

Hello all I am creating a report at work and for some reason am running into some serious problems when using a left join. I have two tables, a u_entities table and a u_activities table where there is a one to many relationship from entities to activities. I need to find out which entities do not have an activity associated with it. So I wanted to left join entities to activities and list the activities that are empty. So my query looks like this

              SELECT *
              FROM (SELECT a.activity_id, e.entity_id, e.acc_name
                    FROM u_entity AS e
                    LEFT JOIN u_activity AS a
                    ON e.entity_id = a.account_id) AS i
              WHERE i.activity_id = ''

This just takes way too long so just to see the results of the left join I tried to just run the sub select in phpmyadmin which looks like this

                    SELECT a.activity_id, e.entity_id, e.acc_name
                    FROM u_entity AS e
                    LEFT JOIN u_activity AS a
                    ON e.entity_id = a.account_id

I ran in to the same problem the server just keeps working and it never finishes. I had to take the tables and run the queries on my local machine using xammp because people need the server and it was locking up. When I run the second query in phpmyadmin on my localhost side, my computer crashes. The entities table has about 20,000 records and the actiivty about 80000 but Ive done inner joins on these tables before with no problem I dont see why this is an issue. Maybe my queries are wrong or something. Ive never done a left join before so I wouldnt know. If there is another way to do this that would be cool but I would really like to know why the left join isnt working correctly. Please any response would be greatly appreciated.

  • 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-20T06:23:14+00:00Added an answer on May 20, 2026 at 6:23 am

    as a note, a quicker way to get entities that don’t have activities is to do

    
    SELECT e.id, ...
    FROM u_entity e
    LEFT JOIN u_activity a ON e.entity_id=a.account_id
    WHERE ISNULL(a.account_id)
    

    About the running slow problem, you want to make sure that you have created indexes on the columns you are using in the joins (in this case, entity_id and account_id) and that they are up to date ( run repair table u_entity and repair table u_activity – if your tables are MyISAM). You shoud really run an EXPLAIN SELECT... (put all your query after the EXPLAIN part) and post the result here to get better help.

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

Sidebar

Related Questions

hello all i am using this code to show flip animation...... i have a
NOTE: Using .NET 2.0, and VS2005 as IDE Hello all, I'm working on logging
I am trying to output all of my database reports into one report. I'm
Hello all Windows Mobile Experts! I have really drowned in the world of developing
Hello friends i need a book/ tutorials for rails without using scoffold. All the
I am using jQuery and creating now search. And i want to change all
Hello all I am trying to work through (learn) MVC3 and I was playing
Hello Guys! I have been trying to create a cool Image Slider using Jquery!
Hi i wanna work with some bluetooth communication using my Android device. How can
Hello all you helpful folks @ stackoverflow! Best resources for Java GUI's? Looking at

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.