Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To insert a CD, you should be able to use something like:</p> <pre><code>INSERT INTO cd (suppliername, producername, title, type, year) VALUES ('Sony', 'Gold Records', 'My CD Title', 'My CD Type', 2008) </code></pre> <p>I'm not going to give you a full answer to your second question since I'm assuming this is homework. I will give you some guidance though. </p> <p>First, if you want a list of producers, you will need to do</p> <pre><code>SELECT * FROM producer </code></pre> <p>But you don't want every producer, you only want the ones that produced CDs released in 1999. How can you get a list fo those CDs? With another query:</p> <pre><code>SELECT * FROM cd WHERE year = 1999 </code></pre> <p>So how do you combine these? With something like:</p> <blockquote> <p>SELECT * FROM producer, cd where cd.producername = producer.name and cd.year = 1999</p> </blockquote> <p>The query that you need is more complex, you need to include the fact that the artist is Yoko Ono but the artist is not in the Cd table, it's in the Song table. That means that you need another join with the Song table. To give you another clue, consider the question, how do I see all Cds released by a particular artist? If you want to see all songs by a particular artist, that's easy:</p> <pre><code>SELECT * FROM Song WHERE artist = 'Yoko Ono' </code></pre> <p>What about the Cds? You could do:</p> <pre><code>SELECT * FROM Cd, Song WHERE Song.CdTitle = Cd.Title </code></pre> <p>Your final query will need to select from all three tables and you'll need all of the constraints to be in place.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload