File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes subqueries help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "subqueries help! " Watch "subqueries help! " New topic
Author

subqueries help!

bhavin ragha
Greenhorn

Joined: Mar 28, 2012
Posts: 17
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

Joined: Mar 28, 2012
Posts: 860

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

Joined: Mar 28, 2012
Posts: 17
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!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: subqueries help!
 
Similar Threads
out putting a table but putting null in the rows where the attributes are not listed. (outer join)
matching rows from one table to another
inner / sub / inline query
The dreaded null pointer exception
Correlated subqueries in HQL Select Clause