开发者

Ruby: JSON result for several depending tables

I am using working with the ruby blog example. So I have the tables posts, comments and tags. The posts table is related 1 to many comments and tags. This works great. - The point I don't get is how to get a single JSON response for a post at his depending records (tags and comments)? - How is the URL format to get all comments of the first post?

开发者_Python百科Thanks a lot, Vanessa


You would join the posts table with the comments table on post_id. Something like this:

 Select comments from comments, posts where posts.post_id = <id of post you want comments of> and posts.id = comments.post_id
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜