/*Displays employees’ last names and the Job Title and GROUP Job Title*/
USE [EXAMPLEDB]
SELECT empLName
FROM tblEmployee
这是我感到困惑的地方,如何使用包含员工姓氏和另一个员工职位的两个不同表来执行此操作?
SELECT jobTitle
FROM tblJobTitle
GROUP BY jobTitle
这些是我的表:
--This Code Creates the Job Title Table--
CREATE TABLE [SHATTKudlerFineFoods].dbo.tblJobTitle
(
jobJobID varchar (4) CONSTRAINT PK_jobJobID PRIMARY KEY Not Null,
jobJobClass varchar (60) Not Null,
jobTitle varchar (60) Not Null,
jobDescription varchar (300) Not Null,
jobStatus varchar (11) Not Null
)
--This Code Creates the Employee Table--
CREATE TABLE [SHATTKudlerFineFoods].dbo.tblEmployee
(
empEmpID varchar (3) CONSTRAINT PK_empEmployeeID PRIMARY KEY Not Null,
empLName varchar (20) Not Null,
empFName varchar (15) Not Null,
empAddress varchar (30) Not Null,
empCity varchar (20) Not Null,
empState varchar (2) Not Null,
empZIPCode varchar (5) Not Null,
empAreaCode varchar (3) Not Null,
empPhoneNo varchar (8) Not Null,
empGender varchar (1) Not Null,
empDOB smalldatetime Not Null,
empAge Tinyint Not Null,
empHireDate smalldatetime Not Null,
empNoOfExempt Tinyint Not Null,
empMaritalStatus varchar (3) Not Null,
empSalary money Not Null,
empStoreID varchar (4) CONSTRAINT FK_strStoreID FOREIGN KEY REFERENCES
tblStores(strStoreID) Not Null,
empJobID varchar (4) CONSTRAINT FK_jobJobID FOREIGN KEY REFERENCES
tblJobTitle(jobJobID) Not Null
)