SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Lookup Tables Empty?

    Hi there,

    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!

  2. #2
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  3. #3
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,263
    Mentioned
    115 Post(s)
    Tagged
    1 Thread(s)
    No they should not be empty. There should be data which ties the two together.

    Example:

    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)
    1, 1
    2, 2
    2, 3


    I think you missed a step somewhere when you created your table - you forgot to populate them.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  4. #4
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    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

    Code MySQL:
    mysql> SELECT joketext 
        -> FROM joke INNER JOIN jokecategory 
        ->   ON joke.id = jokeid 
        -> INNER JOIN category 
        ->   ON categoryid = category.id 
        -> WHERE name = "Knock-knock";

  5. #5
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    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


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •