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 ...
a source to share
You should look at Sql Server TABLE ALIASING
Become familiar with SELECT (Transact-SQL) and search for an alias
a source to share
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
a source to share