SQL语法新手学生

发布于 2024-08-29 22:30:51 字数 528 浏览 4 评论 0原文

描述以下 SQL 查询的输出:

select custId, name
from customer
where region = "New York"
UNION 
select cust.custId, cust.name
from customer cust
where cust.custId IN (select cust_order.custId
from customer_order cust_order, company_employee comp_emp
where cust_order.salesEmpId = comp_emp.empId
AND comp_emp.name = 'DANIEL');

我的问题是:在包含 from customer cust 的行中,“cust”引用的是 customer 表中的列?

这是一个家庭作业问题,我已经确定了导致这条线的组件 我认为 cust 是客户表中的一列...... 我并不是要求一个整体解决方案,只是如果我走在正确的轨道上的话,请给予一点鼓励......

Describe the output of the following SQL query:

select custId, name
from customer
where region = "New York"
UNION 
select cust.custId, cust.name
from customer cust
where cust.custId IN (select cust_order.custId
from customer_order cust_order, company_employee comp_emp
where cust_order.salesEmpId = comp_emp.empId
AND comp_emp.name = 'DANIEL');

My question is: at the line which contains from customer cust is 'cust' referring to a column in the customer table?

This is a homework question I have identified the components leading up to this line
and I think that cust is a column in the customer table...
I am not asking for an overall solution just a bit of encouragement if I am on the right track...

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

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

发布评论

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

评论(8

枕花眠 2024-09-05 22:30:51

cust 是 Customer 表的别名。因此,您可以编写 cust.custId,而不是编写 customer.custId

cust is an alias for the Customer table. So instead of writing customer.custId, you can write cust.custId

网白 2024-09-05 22:30:51

您应该查看 Sql Server TABLE ALIASING

仔细查看 SELECT Clause ( Transact-SQL) 并搜索别名

You should have a look at Sql Server TABLE ALIASING

Have a closer look at SELECT Clause (Transact-SQL) and search for alias

追我者格杀勿论 2024-09-05 22:30:51

Cust 是客户表的别名。它用于使您不必到处拼写整个表名。

Cust is an alias on the customer table. It is used to enable you to not have to spell out the whole table name everywhere.

难得心□动 2024-09-05 22:30:51

否 - 它为表创建一个别名,

  • 因此每次键入的内容较少
  • ,并且可以处理您想要在同一查询中使用表的多个“副本”的情况。

No - its creating an alias for the table

  • so there's less to type each time
  • and to deal with the scenario where you want to use multiple 'copies' of the table in the same query.
转身以后 2024-09-05 22:30:51

cust 是 customer 的别名,可以缩短键入和阅读的时间。

cust is an alias for customer to make it shorter to type and read.

桃酥萝莉 2024-09-05 22:30:51

“cust”只是“customer”表名的别名。它允许您编写“cust.name”而不是“customer.name”

'cust' is just an alias for the 'customer' table name. It allows you to write 'cust.name' rather than 'customer.name'

谎言月老 2024-09-05 22:30:51

cust 是客户表的别名。

由于为了查询的目的,查询将一个表视为两个单独的表(或至少是结果集),这使得数据库知道当您说“Customers”作为表名时,您指的是来自 New 的表约克,而“Cust”则表示销售人员姓名为 Daniel 的公司。

别名的描述如下: http://www.w3schools.com/sql/sql_alias.asp< /a>

cust is an alias for the customer table.

Since the query is looking at one table as two separate tables (or at least result sets) for the purposes of the query, this allows the DB to know that when you say "Customers" as the table name, you mean the ones from New York, while "Cust" means ones where the sales employee name is Daniel.

Alias names are described here: http://www.w3schools.com/sql/sql_alias.asp

听,心雨的声音 2024-09-05 22:30:51

“cust”用作“customer”表的别名。

"cust" is used as an alias of the "customer" table.

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