{"action":"created","issue":{"url":"https://api.github.com/repos/brianc/node-sql/issues/211","labels_url":"https://api.github.com/repos/brianc/node-sql/issues/211/labels{/name}","comments_url":"https://api.github.com/repos/brianc/node-sql/issues/211/comments","events_url":"https://api.github.com/repos/brianc/node-sql/issues/211/events","html_url":"https://github.com/brianc/node-sql/issues/211","id":58333548,"number":211,"title":"Issue with alias","user":{"login":"Hiteshm01","id":4463191,"avatar_url":"https://avatars.githubusercontent.com/u/4463191?v=3","gravatar_id":"","url":"https://api.github.com/users/Hiteshm01","html_url":"https://github.com/Hiteshm01","followers_url":"https://api.github.com/users/Hiteshm01/followers","following_url":"https://api.github.com/users/Hiteshm01/following{/other_user}","gists_url":"https://api.github.com/users/Hiteshm01/gists{/gist_id}","starred_url":"https://api.github.com/users/Hiteshm01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hiteshm01/subscriptions","organizations_url":"https://api.github.com/users/Hiteshm01/orgs","repos_url":"https://api.github.com/users/Hiteshm01/repos","events_url":"https://api.github.com/users/Hiteshm01/events{/privacy}","received_events_url":"https://api.github.com/users/Hiteshm01/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-02-20T10:28:05Z","updated_at":"2015-02-20T20:19:04Z","closed_at":null,"body":"While using alias I got a query like below one, \r\n\r\n```SELECT `user`.`name`, `subposts`.`content` FROM `user` AS `user_test` INNER JOIN (SELECT `postsss`.`content`, MAX(`postsss`.`userId`) AS `userId_max` FROM `post` AS `postsss`) subposts ON (`user`.`id` = ?)```\r\n\r\nShouldn't user.name be replaced with user_test.name?"},"comment":{"url":"https://api.github.com/repos/brianc/node-sql/issues/comments/75311872","html_url":"https://github.com/brianc/node-sql/issues/211#issuecomment-75311872","issue_url":"https://api.github.com/repos/brianc/node-sql/issues/211","id":75311872,"user":{"login":"danrzeppa","id":842673,"avatar_url":"https://avatars.githubusercontent.com/u/842673?v=3","gravatar_id":"","url":"https://api.github.com/users/danrzeppa","html_url":"https://github.com/danrzeppa","followers_url":"https://api.github.com/users/danrzeppa/followers","following_url":"https://api.github.com/users/danrzeppa/following{/other_user}","gists_url":"https://api.github.com/users/danrzeppa/gists{/gist_id}","starred_url":"https://api.github.com/users/danrzeppa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danrzeppa/subscriptions","organizations_url":"https://api.github.com/users/danrzeppa/orgs","repos_url":"https://api.github.com/users/danrzeppa/repos","events_url":"https://api.github.com/users/danrzeppa/events{/privacy}","received_events_url":"https://api.github.com/users/danrzeppa/received_events","type":"User","site_admin":false},"created_at":"2015-02-20T20:19:04Z","updated_at":"2015-02-20T20:19:04Z","body":"My concern is that\r\n```javascript\r\nvar query=user.select(user.name).from(user.as(\"a\"))\r\n```\r\nGenerates invalid SQL:\r\n```sql\r\nSELECT `user`.`name` FROM `user` AS `a`\r\n```\r\nIf this did generate working sql:\r\n```sql\r\nSELECT `a`.`name` FROM `user` AS `a`\r\n```\r\nIt wouldn't break any self joins, since you've already aliased the other table as well.\r\n\r\nRegarding whether it's actually possible to implement this, that I don't know. I haven't dug into the code surrounding aliases enough to know yet."}}