MySQL query problem

Discussion in 'MySQL' started by heroic, Jul 18, 2010.

  1. #1
    Hi,

    I am trying to get data from a table, using the primitive join

    SELECT feeds.id,feeds.text,feeds.from,feeds.to,feeds.time FROM `feed_replies`,`feeds`,`friendships` WHERE ((feeds.from = '1') OR (feeds.to = '1') OR (friendships.from = '1' AND feeds.to = friendships.to) OR (feed_replies.from = '1' AND feed_replies.feed_id = feeds.id)) AND feeds.not_allowed NOT LIKE '%|1|%' ORDER BY feeds.time DESC LIMIT 15
    Code (markup):
    This is the query i am using... oddly enough it is giving me no results whatsoever, even though i have data in the feeds table, and atleast one of them has the from field set to 1.

    If i remove the other tables from the FROM part and from the WHERE part it is working just fine...

    What could I be doing wrong? Also is there a way to improve this query? Make it faster or smthng?

    Thanks :)
     
    heroic, Jul 18, 2010 IP
  2. sketchx

    sketchx Member

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    Can you explain what you are trying to return exactly?

    I would need more info on your data.

    Which table is the main table? are the other one optional?

    Is there a reason why you use the primitive joins?

    --------------------------------------------------------------------
    SELECT feeds.id,feeds.text,feeds.from,feeds.to,feeds.time
    FROM `feed_replies`
    INNER JOIN `feeds` ON feed_replies.feed_id = feeds.id
    INNER JOIN `friendships` ON feeds.to = friendships.to
    WHERE
    (feeds.from = '1'
    OR feeds.to = '1'
    OR friendships.from = '1'
    OR feed_replies.from = '1' )
    AND feeds.not_allowed NOT LIKE '%|1|%' ORDER BY feeds.time DESC LIMIT 15
     
    sketchx, Jul 22, 2010 IP