根据时间戳连接表

时间:2012-01-07 19:00:44

标签: php mysql join

你好朋友正在研究一个项目并建立一个通知系统。

我需要加入几张桌子。这样我就可以根据通知表的时间戳获取数据。

通知表

notification table

此类型用于通知类型。所以我想按时间戳和

订购

类型墙贴表

type wall post table is

类型墙评论表

type wall comment table is

最后用户表获取所有其他表中id的名称是

用户表

user table

真的无法加入这些。任何人都可以帮忙.....

1 个答案:

答案 0 :(得分:1)

我看到user_id是所有表中的公共属性,因此您可以在此属性上加入表。

然后您可以选择与时间戳对应的表

Select * FROM notification_table INNER JOIN comment_table ON 
notification_table.user_d = comment_table.uid_fk INNER JOIN wallpost_table
ON comment_table.uid_fk == wallpost_table.uid_fk INNER JOIN user_table ON 
wallpost_table.uid == user_table.uid