Multiple join query

Discussion in 'MySQL' started by Silver89, Mar 28, 2010.

  1. #1
    hi,

    I'm trying to do the following join to get information from 3 different tables, it's not too difficult to understand and should be quite self explanatory but it's giving me problems?

    
    SELECT forumPosts.username, forumRooms.title, forumRooms.lastPost, user.id  
    FROM forumPosts, forumRooms, user 
    WHERE forumPosts.forumTopic=forumRooms.id AND forumPosts.username=user.username
    ORDER BY forumPosts.id DESC 
    LIMIT 1
    
    Code (markup):
    It works but it takes a very long time?
     
    Last edited: Mar 28, 2010
    Silver89, Mar 28, 2010 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    What are the indexes on the tables? Do you have any foreign key relationships? How large are these tables?
     
    jestep, Mar 29, 2010 IP