Two LEFT JOIN MySQL problems: Limiting queries & using IF for the join

Discussion in 'MySQL' started by Kyosys, Mar 9, 2009.

  1. #1
    Alright, I have two problems I hope you can help me with.

    For one, I have this LEFT JOIN, which will only ever find one result (user) for each database entry (comment) on the other table (comments table). I want to limit it to stop searching the user table after having found a user for efficiency reasons. How would I go on about this?
    Note that I don't want to LIMIT the whole query.

    Secondly, I'd like it to do the join if based. If the userid on the comments table is 0 it should not search the user table for a matching user at all. How would I do this? I'm familiar with IFs, but I don't know how to apply it to parts of a query (the join part)
     
    Kyosys, Mar 9, 2009 IP