{"action":"created","issue":{"url":"https://api.github.com/repos/astaxie/beego/issues/579","labels_url":"https://api.github.com/repos/astaxie/beego/issues/579/labels{/name}","comments_url":"https://api.github.com/repos/astaxie/beego/issues/579/comments","events_url":"https://api.github.com/repos/astaxie/beego/issues/579/events","html_url":"https://github.com/astaxie/beego/issues/579","id":31618882,"number":579,"title":"[orm] 关联查询是否必须设置外键？","user":{"login":"lubia","id":2741940,"avatar_url":"https://avatars.githubusercontent.com/u/2741940?v=3","gravatar_id":"","url":"https://api.github.com/users/lubia","html_url":"https://github.com/lubia","followers_url":"https://api.github.com/users/lubia/followers","following_url":"https://api.github.com/users/lubia/following{/other_user}","gists_url":"https://api.github.com/users/lubia/gists{/gist_id}","starred_url":"https://api.github.com/users/lubia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lubia/subscriptions","organizations_url":"https://api.github.com/users/lubia/orgs","repos_url":"https://api.github.com/users/lubia/repos","events_url":"https://api.github.com/users/lubia/events{/privacy}","received_events_url":"https://api.github.com/users/lubia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2014-04-16T07:36:12Z","updated_at":"2015-12-30T09:02:57Z","closed_at":null,"body":"想要实现关联查询，但又不想使用外键造成表间耦合\r\n\r\n```\r\ntype Item struct{\r\n    ItemID string\r\n    AccountID string\r\n    Name string\r\n}\r\n\r\ntype Order struct{\r\n    OrderID string\r\n    Year string\r\n    ItemID string\r\n}\r\n```\r\n这两个struct会映射到数据库，ItemID这个字段在两个字段有关联关系，现在已知Item中的AccountID，想查到Order中的Year字段。\r\n\r\n不使用外键的情况下，请问怎样查询到想要的结果?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/astaxie/beego/issues/comments/167960594","html_url":"https://github.com/astaxie/beego/issues/579#issuecomment-167960594","issue_url":"https://api.github.com/repos/astaxie/beego/issues/579","id":167960594,"user":{"login":"lei-cao","id":136104,"avatar_url":"https://avatars.githubusercontent.com/u/136104?v=3","gravatar_id":"","url":"https://api.github.com/users/lei-cao","html_url":"https://github.com/lei-cao","followers_url":"https://api.github.com/users/lei-cao/followers","following_url":"https://api.github.com/users/lei-cao/following{/other_user}","gists_url":"https://api.github.com/users/lei-cao/gists{/gist_id}","starred_url":"https://api.github.com/users/lei-cao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lei-cao/subscriptions","organizations_url":"https://api.github.com/users/lei-cao/orgs","repos_url":"https://api.github.com/users/lei-cao/repos","events_url":"https://api.github.com/users/lei-cao/events{/privacy}","received_events_url":"https://api.github.com/users/lei-cao/received_events","type":"User","site_admin":false},"created_at":"2015-12-30T09:02:57Z","updated_at":"2015-12-30T09:02:57Z","body":"@astaxie  can close"}}