[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 781
  • Last Modified:

Equivalent LEFT JOIN SQL?

A while back I asked a question which helped me to build the following (first) SQL statement. Out of interest. Could somebody tell me if both of the following statements are identical. Is the alias just for convenience, or could it alter the output in any way?

SELECT t1.* FROM user_group_link AS t2 LEFT JOIN user AS t1 ON t2.user_id = t1.id WHERE t2.group_id=[b]INPUT[/b]

Open in new window


SELECT user.* FROM user_group_link LEFT JOIN user ON user_group_link.user_id = user.id WHERE user_group_link.group_id=[b]INPUT[/b]

Open in new window

0
numberkruncher
Asked:
numberkruncher
  • 2
1 Solution
 
markterryCommented:
Yes, they are the same. Aliases are simply to shorten your object names in a query. This way you can give your tables descriptive names, and not have to be constantly inconvienced by the name while typing.
0
 
markterryCommented:
in fact, if the colum names are unique to all tables, you do not even need the tablename.columnname, you can just put colum name. But this is not good practice.
0
 
numberkruncherAuthor Commented:
Thanks, I wasn't sure what the AS was giving an alias to the table name or whether it was giving a name to a set of results which had to be re-addressed.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now