MYSQL选择代表不同工作室的销售人员(没有重复)

时间:2015-01-26 03:54:36

标签: mysql sql

所以我需要列出代表不同工作室的每个销售人员的salesID,firstName,lastName,我有以下内容(这是来自SalesPeople表)

   +---------+-----------+----------+---------------------+
   | SalesID | firstName | LastName | StudioName          |
   +---------+-----------+----------+---------------------+
   |       1 | Bob       | Bentley  | MakeTrax            |
   |       1 | Bob       | Bentley  | Lone Star Recording |
   |       1 | Bob       | Bentley  | Pacific Rim         |
   |       2 | Lisa      | Williams | MakeTrax            |
   |       2 | Lisa      | Williams | Lone Star Recording |
   |       2 | Lisa      | Williams | Pacific Rim         |
   |       3 | Clint     | Sanchez  | MakeTrax            |
   |       3 | Clint     | Sanchez  | Lone Star Recording |
   |       3 | Clint     | Sanchez  | Pacific Rim         |
   |       4 | Scott     | Bull     | MakeTrax            | 
   |       4 | Scott     | Bull     | Lone Star Recording |
   |       4 | Scott     | Bull     | Pacific Rim         |
   +---------+-----------+----------+---------------------+

所以我想要的只是三个记录显示三个不同工作室的销售人员

**I've tried**

SELECT DISTINCT a.SalesID, a.FirstName, a.LastName, b.StudioName FROM SalesPeople a JOIN Studios b;

但我得到了这个

   +---------+-----------+----------+---------------------+
   | SalesID | firstName | LastName | StudioName          |
   +---------+-----------+----------+---------------------+
   |       1 | Bob       | Bentley  | MakeTrax            |
   |       1 | Bob       | Bentley  | Lone Star Recording |
   |       1 | Bob       | Bentley  | Pacific Rim         |
   |       2 | Lisa      | Williams | MakeTrax            |
   |       3 | Clint     | Sanchez  | Lone Star Recording |
   |       3 | Clint     | Sanchez  | Pacific Rim         |
   |       4 | Scott     | Bull     | MakeTrax            |
   |       4 | Scott     | Bull     | Lone Star Recording |
   |       4 | Scott     | Bull     | Pacific Rim         |
   +---------+-----------+----------+---------------------+

如何区分以找到代表一个工作室的三个不同的人?

1 个答案:

答案 0 :(得分:2)

从您的不同内容中删除StudioName。