Solved

Equivalent LEFT JOIN SQL?

Posted on 2011-02-21
3
767 Views
Last Modified: 2012-05-11
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
Comment
Question by:numberkruncher
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
markterry earned 500 total points
Comment Utility
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
 
LVL 6

Expert Comment

by:markterry
Comment Utility
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
 
LVL 13

Author Comment

by:numberkruncher
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now