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

  • Home
  • SEARCH
  • 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 1039591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:07:07+00:00 2026-05-16T15:07:07+00:00

I have a MySQL table. Let’s call it Widgets. The Widget table has 3

  • 0

I have a MySQL table. Let’s call it Widgets. The Widget table has 3 fields: id, type_id, and name. I want, in one query, to get all the widgets that share a type_id with the Widget named ‘doodad’. I’ve written 2 queries:

  1. Give me the type_id of the widget with the name ‘doodad’.
  2. Give me all widgets with that type_id.

This works. Each query, independently achieves its goal.

But when I combine them into a single nested query, it runs forever, infinite loop style. It looks like this:

SELECT * FROM widgets WHERE type_id IN  (
    SELECT type_id FROM widgets WHERE name = 'doodad'
);

Can anyone explain this? Is it because I am writing a nested query which is operating on the same table twice?

Little wheel, why spinnest thou?

  • 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-16T15:07:08+00:00Added an answer on May 16, 2026 at 3:07 pm

    There is an issue in MySQL and in where even uncorrelated subqueries are treated as though they were correlated and re-evaluated for each row.

    In the explain plan the select type will likely be showing as dependant subquery rather than just subquery as would be desired.

    I suggest trying the approach described at the end of this article of using a derived table to materialize the inner result set.

    Or alternatively you could look at the constify procedure here to see if it will assist you in getting around this issue.

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

Sidebar

Ask A Question

Stats

  • Questions 525k
  • Answers 525k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes, it is OK, jQuery will queue and merge them… May 16, 2026 at 10:17 pm
  • Editorial Team
    Editorial Team added an answer It's unclear what programming language you're using or are preferring,… May 16, 2026 at 10:17 pm
  • Editorial Team
    Editorial Team added an answer This isn't possible as far as I know. There is… May 16, 2026 at 10:17 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Let's say I have a MySQL table, people . Each record comprises a variety
Let's say I have a MySQL table that is something like this: software table:
let's say i have this mysql table structure : table : articles ---------------- id
Let's say I have a mysql table, called foo with a foreign key option_id
I have one mysql table 'alfa' that will contain the primary key of another
Let's say I have players table. It consists with 3 rows(it has much more,
i have 2 tables 1st table called services has id_service, name, date. description 2nd
I have a mysql table containing news data and categories and i'm trying to
I have this mysql table called comments which looks like this: commentID parentID type
I have a mysql Database and 2 tables let's say clients and schools. Now

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.