Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Statement t1, t2 etc

Im quite new to SQL and I'm just trying to find out what it means when you use t1, t2 or t3 etc... I cant get my head around it and would just like to learn about it. I've tried looking all over google but i've found nothing yet... Can you help?

Thanks Mw

like image 745
user1847961 Avatar asked Dec 04 '12 13:12

user1847961


People also ask

What is T1 and T2 in SQL?

A join-condition specifies pairings of T1 and T2, where T1 and T2 are the left and right operand tables of its associated JOIN operator. For all possible combinations of rows T1 and T2, a row of T1 is paired with a row of T2 if the join-condition is true.

What does T stand for in SQL?

T-SQL (Transact-SQL) is a set of programming extensions from Sybase and Microsoft that add several features to the Structured Query Language (SQL), including transaction control, exception and error handling, row processing and declared variables.


1 Answers

t1/t2/t3 are common table aliases for "temp" tables (e.g. subqueries that are made of multiple tables and don't alias nicely).... call it a bit of laziness if that helps :)

SELECT * FROM MyTable t1 means from now on, I'm calling MyTable t1. Another way of writing it would be: SELECT t1.* FROM MyTable t1 or if you didn't use the alias, SELECT MyTable.* FROM MyTable

like image 196
Eli Gassert Avatar answered Oct 25 '22 18:10

Eli Gassert