MySQL Forums
Forum List  »  Newbie

Query help
Posted by: screen mate
Date: July 22, 2005 07:54AM

I am new to sql and need some help with this query. The tables are arranged as under:

Table name: ARTIST
Columns: ArtistID, GenreID
Values:
Sting Pop
Sting Rock
Bryan Rock

Table Name: GENRE
Column: GenreID
Values:
Electronica
Country
Pop
Rock


Table Name: Criteria
Column: GenreID
Values:
Pop
Rock

I am trying to use the values in the criteria table to search the artist table to return the name of the artists that have "all" (AND-clause) the criteria values (belong to all the genres in the criteria table). I need just the name of the artist (single row) but I am getting multiples.

Multiple rows (I need just one row for all the criteria values)

select ArtistID
from artist a, criteria c
WHERE a.GenreID = c.GenreID

I don't want an OR-clause:
select ArtistID
from artist a
WHERE a.GenreID in (select genreID from criteria)

thanks

Options: ReplyQuote


Subject
Written By
Posted
Query help
July 22, 2005 07:54AM
July 22, 2005 08:31AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.