Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

subqueries help!

 
bhavin ragha
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need to use subqueries, and list the names of the members of band Radiohead. Assume you do
not know the band_id of Radiohead.

table info:
bands(band_id, band_name) represents a list of bands

band_members(band_id, name, dob, country, sex) represents the members of the
bands in relation bands

here is what i have so far
SELECT band_members.name
FROM band_members
WHERE band_members.name in (SELECT bands.band_name
FROM bands
WHERE bands.band_name = 'Radiohead');
 
William P O'Sullivan
Ranch Hand
Posts: 859
Chrome IBM DB2 Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SELECT band_members.name
FROM band_members
WHERE band_members.name in (SELECT bands.band_name <-- Incorrect
FROM bands
WHERE bands.band_name = 'Radiohead');

This would look for band member name as 'Radiohead'.

You need to use the band_id (hint).

Try it.. I'll help.

Pat.
 
bhavin ragha
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William P O'Sullivan wrote:SELECT band_members.name
FROM band_members
WHERE band_members.name in (SELECT bands.band_name <-- Incorrect
FROM bands
WHERE bands.band_name = 'Radiohead');

This would look for band member name as 'Radiohead'.

You need to use the band_id (hint).

Try it.. I'll help.

Pat.


oh i see... thank you!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic