开发者

Linking 2 tables in a single PHP output.. best way? PHP/MySQL

I'm trying to link two tables. I want a user on my site to be able to 'follow' a user a开发者_如何学运维nd see their updates. I have two tables

Users | Publish
===============
userid|userid
follow|publish_id
      |publish_content

In users I have their userID and who they are following. In the publish table I have what they posted, their logged ID's and the content. If I want to display this to the follower, what is the best way of going about it? Linking up the two tables with the posts that the user would want to see? Would joining be the best route? Thanks!


SELECT a.userid a.publish_id, a.publish_content FROM Publish a, Users b WHERE a.userid IN b.follow

if follow is of type varchar and gives the list of friends the user if following in a comma separated format, this query will give the details of all the users the present user if following


SELECT publish_id, publish_content 
     FROM Publish JOIN Users ON Publish.userid = Users.userid 
     WHERE Users.follow = "%user%"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜