Get only one row out of join query
I hvae created facebook like wall. Right now I had a separate wall for
every user. Every wall had it's own ID (based on user id). So if user id
is 51 then query gets all posts based on this id. Query:
SELECT *, xx_skelbimai.id as ID FROM xx_skelbimai
JOIN #__comprofiler b ON b.user_id = xx_skelbimai.userid
JOIN xx_users c ON b.user_id =c.id WHERE userid=$id
ORDER BY xx_skelbimai.id DESC
But now I need to create a mutual wall, so I can display all users wall
posts, my thougt was that I can use query like this:
SELECT *, xx_skelbimai.id as ID FROM `xx_skelbimai`
JOIN xx_comprofiler b
JOIN xx_users
But the result was not what I was expecting for. I got a huge ammount of
rows with all users and one post written by user id 11(right now I have
only one post). What do I need to change in this or that query (first one)
to get only posts which are in table xx_skelbimai and info about my users
(table xx_comprofiler and xx_users) ?
No comments:
Post a Comment