SQL Syntax Newbie Student

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, is the row that contains from customer cust

"cust" referring to a column in the customers table?

This is a homework question that I have defined with components leading to this row and I think cust is a column in the customer table ... I am not asking for a general solution just a little encouragement if I am on the right track ...

+2


a source to share


8 answers


You should look at Sql Server TABLE ALIASING



Become familiar with SELECT (Transact-SQL) and search for an alias

+1


a source


cust

is an alias for the Customer table. Therefore, instead of writing, customer.custId

you can writecust.custId



+5


a source


Cust is an alias in the customer table. It is used to allow you not to specify the entire table everywhere.

+1


a source


No - create an alias for the table

  • so there is less to type every time
  • and consider a scenario where you want to use multiple "copies" of a table in the same query.
+1


a source


cust is an alias for the client, which makes it shorter to enter and read.

+1


a source


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

+1


a source


cust is an alias for the clients table.

Since the query treats one table as two separate tables (or at least result sets) for query purposes, this lets the DB know that when you say "clients" as the table name, you mean from New York, then as "Cust" means those where the sales person's name is Daniel.

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

+1


a source


"cust" is used as an alias for the "client" table.

0


a source







All Articles