SQL语法新手学生
描述以下 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
cust
是 Customer 表的别名。因此,您可以编写cust.custId
,而不是编写customer.custId
cust
is an alias for the Customer table. So instead of writingcustomer.custId
, you can writecust.custId
您应该查看 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
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.
否 - 它为表创建一个别名,
No - its creating an alias for the table
cust 是 customer 的别名,可以缩短键入和阅读的时间。
cust is an alias for customer to make it shorter to type and read.
“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'
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
“cust”用作“customer”表的别名。
"cust" is used as an alias of the "customer" table.