[英]Retrieve columns from table A in comparsion to table B column values where there is no common relationship between two tables
A new bird to SQL. SQL的新鸟。
Table A name is EmployeeDetails which has four columns. 表名称是EmployeeDetails,它有四列。
EmployeeID FirstName, LastName, NativeState
1 Frank Dyre FL
2 John Smith AL
3 Taylor Cox GA
Table B is CompanyDetails which has three columns 表B是CompanyDetails,其中包含三列
CompanyID CompanyName HeadQuatersState
1 Steve's FL
2 Johnson NY
3 Huston GA
Now in both the tables there is no same columns. 现在,两个表中没有相同的列。 But Native State and HeadQuatersStat have common states.
但是Native State和HeadQuatersStat具有共同的状态。
how can I retrieve first and lastname of an employee from employeeDetails table where the nativestate is not equals to company headquarters state. 如何从employeeDetails表中检索员工的姓氏和名字,其中原始状态不等于公司总部状态。
Expected result is John Smith. 预期结果是约翰·史密斯。
I think this is what your looking for 我想这就是你要找的
SELECT EmployeeID,FirstName + ' ' + LastName 'Employee'
FROM EmployeeDetails
WHERE NativeState NOT IN (SELECT HeadQuartersState
FROM CompanyDetails)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.