-1

我有一个数据库,其中存在一个表员工,如下所示

+-----------+--------------+-------------+
| LastName  | DepartmentID | projectname |
+-----------+--------------+-------------+
| Rafferty  |           31 |  ims        |
| Jones     |           33 |  ibm server |
| Steinberg |           33 |  null       |
| Robinson  |           34 |  ims        |
| Smith     |           34 |  ibmserver  |
| John      |         NULL |  ims        |
+-----------+--------------+-------------+

我想检索那些从事琼斯工作的项目的姓氏

Select * from employee ???

请有任何建议

4

1 回答 1

1

以下应该是您的查询 -

Select * from employee where projectname = (select projectname from employee where LastName = 'Jones');

in由于琼斯在一个项目中工作,我们没有使用条款。

如果他在多个项目中工作

那么查询可以是 -

Select * from employee where projectname in (select projectname from employee where LastName = 'Jones');

谢谢

于 2013-04-01T11:19:18.160 回答