SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jul 2013
    Location
    South of the equator, then turn left
    Posts
    364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem joining tables with same ID

    Hi everyone,

    I've started a thread in the databases & mysql forum:

    http://www.sitepoint.com/forums/show...eparate-tables

    I am using a "lookup table" which means the same ID might appear multiple times in the table. Now the problem is that the data I'm returning loops out multiple times because of that ID.


    This is the structure of the query. If the hotels_features table has the same hotel id appearing 5 times, the rooms will loop out 5 times as well.

    Code:
    $q = "SELECT column names
    FROM hotels AS h INNER JOIN
    rooms AS r ON r.hotel_id=h.hotel_id INNER JOIN
    hotels_features AS hf ON hf.hotel_id = h.hotel_id INNER JOIN
    features AS f ON f.features_id = hf.features_id
    ...WHERE category = '$category'";

    Perhaps someone will know where the problem lies.


    Thank you in advance.

  2. #2
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,283
    Mentioned
    121 Post(s)
    Tagged
    1 Thread(s)
    I'm going to close this, and move the original thread over here so people can understand the actual problem.without having to jump back and forth....

    THREAD CLOSED
    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


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
  •