Select data from same field but in two different rows, then output to one row
I have a follow table that has follower and a followee fields that
represents user_id in a user table. The user table has the names of the
users, called full_name. I want to create a query that pushes an update
from a post table to all followees when a follower posts. Results to to
look like this:
user.full_name of followee, user.fullname of follower, update of followee.
Code I have is:
SELECT user.user_id, user.user_id, post.update
FROM follow
JOIN post ON post.user_id = follow.follower_user_id
JOIN user ON user.user_id = follow.followee_user_id
Where update.date > DATE_SUB(CURDATE(),INTERVAL 0 DAY)
GROUP BY follow.followee_user_id
It does the right query, but I can't get the follower name to populate. it
just duplicates the followee. Any idea on how to write the select fields?
No comments:
Post a Comment