lou_chou — 2010-03-09T06:23:43-05:00 — #1
I'm working my way through Build Your Own Database Driven Website (3rd Edition) and although it's been excellent thus far, I've hit a snag.
I'm at Chapter 5: Relational Database Design, near the end of the chapter, and I've just established a lookup table called JOKECATEGORY which is drawing information from JOKE and CATEGORY tables.
When I try to SELECT information from JOKECATEGORY it just gives me an EMPTY SET message. Is this normal? I haven't inserted any information to JOKECATEGORY, because I was under the impression it was taking its information from those other tables I mentioned. Am I wrong? Should I be inputting information? Perhaps I've misinterpreted somewhere.
Any help is greatly appreciated!
davemaxwell — 2010-03-11T08:04:13-05:00 — #2
No they should not be empty. There should be data which ties the two together.
In Jokes (format is JokeID, Joke, Punchline)
1, Why Did the Chicken Cross the Road, To Get to the Other Side
2, What is a cows favorite subject in school?, Moo-sic!
3, Where do sheep get their coats cut? At the baa-bershop!
In Category (format is CategoryID, Category
1, Classic Jokes
2, Classic Puns
In your JokeCategory Table, you'd have something like (format CategoryID, JokeID)
I think you missed a step somewhere when you created your table - you forgot to populate them.
lou_chou — 2010-03-11T05:17:11-05:00 — #3
Hmm, perhaps the question I was asking was too bloated. Would anyone be able to tell me this then: is a lookup table meant to be empty?
lou_chou — 2010-03-11T09:42:32-05:00 — #4
Thanks for the reply. I've managed to add the appropriate values to JOKECATEGORY, but I'm still receiving an "empty set" message. This is beginning to get frustrating
Here is the MYSQL code I'm trying to execute, if it's of any use
mysql> SELECT joketext
-> FROM joke INNER JOIN jokecategory
-> ON joke.id = jokeid
-> INNER JOIN category
-> ON categoryid = category.id
-> WHERE name = "Knock-knock";
lou_chou — 2010-03-11T09:51:12-05:00 — #5
SCRATCH THAT! I dialed back the code a bit, and executed it section by section, and found that the WHERE="Knock-knock" statement was the culprit. I change that to search for another thing, and it worked
Thanks very much for the help