I have a MySQL table. Let me call it Widgets. The Widget table has 3 fields: id , type_id and name . I want, in one request, to get all widgets sharing type_id with widgets called "doodad". I wrote 2 questions:
- Give me the type_id of the widget named "doodad".
- Give me all the widgets with this type_name.
It works. Each request independently reaches its goal.
But when I combine them into one subquery, it works forever, an 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'm writing a subquery that works in the same table twice?
Little wheel, why are you cool?
mysql nested
Whit
source share