我正在设计一个用php的博客网站,在那里用户可以手动添加相关的帖子。
我想对所有相关的帖子使用一个自动递增整数。
下表:
Blog:
-id
-related ( it's 0 if there aren't related posts or it contain an autoincremet integer that it is the same for all posts related )
-id_user
-title
-body
-date如果可能的话,我不喜欢使用“相关表”,以避免复杂的查询。
因此,在这种情况下,我需要一种方法来获取自动增量整数,或者您可以向我推荐其他解决方案:)
发布于 2013-05-10 16:16:22
你可以将related设置为NULL,然后你可以检查它是否为NULL --这样就没有相关的帖子了。
要选择所有相关帖子:
SELECT * FROM Blog where related=:blog_idhttps://stackoverflow.com/questions/16477725
复制相似问题