SELECT posts.*, topics.* FROM posts LEFT JOIN topics ON (posts.topicid = topics.topicid) WHERE posts.message LIKE '%bla%' OR topics.title LIKE '%bla%'