{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/5137","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/5137/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/5137/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/5137/events","html_url":"https://github.com/yiisoft/yii2/issues/5137","id":43599904,"number":5137,"title":"Using a joinwith to two different relations on the same table causes alias error","user":{"login":"Sammaye","id":323996,"avatar_url":"https://avatars.githubusercontent.com/u/323996?v=3","gravatar_id":"","url":"https://api.github.com/users/Sammaye","html_url":"https://github.com/Sammaye","followers_url":"https://api.github.com/users/Sammaye/followers","following_url":"https://api.github.com/users/Sammaye/following{/other_user}","gists_url":"https://api.github.com/users/Sammaye/gists{/gist_id}","starred_url":"https://api.github.com/users/Sammaye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sammaye/subscriptions","organizations_url":"https://api.github.com/users/Sammaye/orgs","repos_url":"https://api.github.com/users/Sammaye/repos","events_url":"https://api.github.com/users/Sammaye/events{/privacy}","received_events_url":"https://api.github.com/users/Sammaye/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yiisoft/yii2/labels/type:docs","name":"type:docs","color":"207de5"}],"state":"open","locked":false,"assignee":{"login":"cebe","id":189796,"avatar_url":"https://avatars.githubusercontent.com/u/189796?v=3","gravatar_id":"","url":"https://api.github.com/users/cebe","html_url":"https://github.com/cebe","followers_url":"https://api.github.com/users/cebe/followers","following_url":"https://api.github.com/users/cebe/following{/other_user}","gists_url":"https://api.github.com/users/cebe/gists{/gist_id}","starred_url":"https://api.github.com/users/cebe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cebe/subscriptions","organizations_url":"https://api.github.com/users/cebe/orgs","repos_url":"https://api.github.com/users/cebe/repos","events_url":"https://api.github.com/users/cebe/events{/privacy}","received_events_url":"https://api.github.com/users/cebe/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/yiisoft/yii2/milestones/9","html_url":"https://github.com/yiisoft/yii2/milestones/2.0.x","labels_url":"https://api.github.com/repos/yiisoft/yii2/milestones/9/labels","id":831720,"number":9,"title":"2.0.x","description":"","creator":{"login":"cebe","id":189796,"avatar_url":"https://avatars.githubusercontent.com/u/189796?v=3","gravatar_id":"","url":"https://api.github.com/users/cebe","html_url":"https://github.com/cebe","followers_url":"https://api.github.com/users/cebe/followers","following_url":"https://api.github.com/users/cebe/following{/other_user}","gists_url":"https://api.github.com/users/cebe/gists{/gist_id}","starred_url":"https://api.github.com/users/cebe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cebe/subscriptions","organizations_url":"https://api.github.com/users/cebe/orgs","repos_url":"https://api.github.com/users/cebe/repos","events_url":"https://api.github.com/users/cebe/events{/privacy}","received_events_url":"https://api.github.com/users/cebe/received_events","type":"User","site_admin":false},"open_issues":387,"closed_issues":0,"state":"open","created_at":"2014-10-19T13:49:45Z","updated_at":"2016-02-25T14:03:21Z","due_on":null,"closed_at":null},"comments":10,"created_at":"2014-09-23T07:47:41Z","updated_at":"2016-02-25T14:28:12Z","closed_at":null,"body":"I have an order object with two relations like so:\r\n\r\n```php\r\n\tpublic function getUser()\r\n\t{\r\n\t\treturn $this->hasOne('common\\models\\User', ['id' => 'user_id']);\r\n\t}\r\n\r\n\tpublic function getPartner()\r\n\t{\r\n\t\treturn $this->hasOne('common\\models\\User', ['ns_partner_id' => 'partner_id']);\r\n\t}\r\n```\r\n\r\nwhen I do:\r\n\r\n    <?php foreach($query->joinWith(['partner', 'user'])->each() as $order){ ?>\r\n\r\nI get:\r\n\r\n    SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'tbl_user'\r\n\r\nIs this expected?"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/188809286","html_url":"https://github.com/yiisoft/yii2/issues/5137#issuecomment-188809286","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/5137","id":188809286,"user":{"login":"cebe","id":189796,"avatar_url":"https://avatars.githubusercontent.com/u/189796?v=3","gravatar_id":"","url":"https://api.github.com/users/cebe","html_url":"https://github.com/cebe","followers_url":"https://api.github.com/users/cebe/followers","following_url":"https://api.github.com/users/cebe/following{/other_user}","gists_url":"https://api.github.com/users/cebe/gists{/gist_id}","starred_url":"https://api.github.com/users/cebe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cebe/subscriptions","organizations_url":"https://api.github.com/users/cebe/orgs","repos_url":"https://api.github.com/users/cebe/repos","events_url":"https://api.github.com/users/cebe/events{/privacy}","received_events_url":"https://api.github.com/users/cebe/received_events","type":"User","site_admin":false},"created_at":"2016-02-25T14:28:12Z","updated_at":"2016-02-25T14:28:12Z","body":"related to #7263 "}}