sql select使用mysql查询浏览器

发布于 2024-09-30 15:34:20 字数 154 浏览 4 评论 0原文

我想知道为什么当我使用 MySQL 查询浏览器并双击表名时,sql 语句看起来像这样:

SELECT * FROM database.table t;

where t = 表的第一个字母...这个字母的用途是什么?我只是好奇

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 am just curious

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

吻泪 2024-10-07 15:34:20

t 是表的别名。在使用以下内容编写查询时它会有所帮助:

  • 选择列表中的许多列

  • (许多)连接,其中写入完整的表名称将不可读

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

  • 如果您想要同一个表的 2 个以上副本,您可以使用不同的名称为它们别名:

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

  • 长表/视图名称,持续写入/读取会很麻烦。命名约定有时是罪魁祸首。想象一个数据仓库表,如下所示:

    InvoicesThatAreOverdue_Temp_Holding_20101128

这不是必需的,但 MySQL 查询浏览器正在帮助推广别名的使用。希望它可以帮助开发人员编写可读的代码!

The t is an alias for the table. It helps when writing queries with :

  • many columns in the select list

  • (many) joins where writing the full table name would be unreadable

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

  • if you wanted 2+ copies of the same table, you could alias them with different names:

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

  • long table/view names that would be cumbersome to keep writing/reading. Naming conventions sometimes are the culprit. Imagine a data warehouse table like:

    InvoicesThatAreOverdue_Temp_Holding_20101128

It's not required, but the MySQL Query Browser is helping promote the use of aliases. Here's hoping it helps developers write readable code!

椵侞 2024-10-07 15:34:20

这是一个别名,可以让您缩短参考文献

例如

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

而不是这个

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

It is an alias that will allow you to shorten your references

For example

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

Instead of this

Select * from table1 
Inner Join table2 on table1.PK = table2.FK
小鸟爱天空丶 2024-10-07 15:34:20

它被称为别名:)

在 SQL 中,可以为
表或列。你可以给一个
表或列的另一个名称
使用别名。这可以是一个很好的
如果你有很长的时间或要做的事情
复杂的表名或列名。

It is known as alias :)

In SQL, an alias name can be given to
a table or to a column. You can give a
table or a column another name by
using an alias. This can be a good
thing to do if you have very long or
complex table names or column names.

征﹌骨岁月お 2024-10-07 15:34:20

这是一个表别名。这是关于使用别名的简短教程

It's a table alias. Here is a short tutorial on using aliases.

ぃ双果 2024-10-07 15:34:20

您实际上是在使用快捷方式(别名)为表指定新名称。

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

当您连接多个表时,表别名对于较大的查询非常有用。

You're actually using a shortcut (alias) to give a new name to the table.

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

Table aliasing is pretty useful for larger queries when you're joining multiple tables.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文