Sql select using mysql query browser

I am wondering why when I use MySQL Query Browser and double-click table names, the sql statements look like this:

SELECT * FROM database.table t;

where t = the first letter of the table ... What is the purpose of this letter? I'm just curious

+3
source share
5 answers

tis an alias for the table. This helps when writing queries with:

  • many columns in the selection list

  • (many) appends when the full table name record is unreadable

    Foo f INNER JOIN Customers c on c.ID = f.CustomerID LEFT JOIN BAR b on b.ID=f.ID

  • if you need 2+ copies of the same table, you can use them under different names:

    Invoices i LEFT JOIN Invoices i2 on i.ID = i2.MasterInvoiceID

  • / , , /. . , :

    InvoicesThatAreOverdue_Temp_Holding_20101128

, MySQL Query Browser . , , !

+7

,

Select * from table1 t1
Inner Join table2 t2 on t1.PK = t2.FK

Select * from table1 
Inner Join table2 on table1.PK = table2.FK
+3

:)

SQL . . , .

+2

(), .

// this is the full command but you can leave out AS if you want
SELECT * FROM database.table AS t;

.

+1
source

This is a table alias. The following is a short short course using aliases.

+1
source

Source: https://habr.com/ru/post/1772699/


All Articles