0

次のクエリに問題があります。

SELECT costingjobtimes.TimeStamp, costingdepartment.DeptDesc,  costingemployee.Name, costingjobtimes.TimeElapsed FROM costingemployee INNER JOIN (costingdepartment INNER JOIN costingjobtimes ON costingdepartment.DeptID = costingjobtimes.DeptID) ON costingemployee.EmployeeID = costingjobtimes.EmployeeID;

costingjobtimes データベースのすべての行が返されることを期待していますが、現在は 4 行しか返されていません。

基本的に、私は3つのテーブルを持っています。(costingjobtimes、costingdepartment、costingemployee) それらは次のとおりです。

mysql> DESCRIBE costingemployee
    -> ;
+------------+------------+------+-----+---------+-------+
| Field      | Type       | Null | Key | Default | Extra |
+------------+------------+------+-----+---------+-------+
| EmployeeID | varchar(8) |      | PRI |         |       |
| Name       | text       |      |     |         |       |
+------------+------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

mysql> DESCRIBE costingdepartment
    -> ;
+----------+------------------+------+-----+---------+-------+
| Field    | Type             | Null | Key | Default | Extra |
+----------+------------------+------+-----+---------+-------+
| DeptID   | int(10) unsigned |      | PRI | 0       |       |
| DeptDesc | text             |      |     |         |       |
+----------+------------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

mysql> DESCRIBE costingjobtimes
    -> ;
+-------------+------------------+------+-----+---------------------+-----------
-----+
| Field       | Type             | Null | Key | Default             | Extra
     |
+-------------+------------------+------+-----+---------------------+-----------
-----+
| id          | int(10) unsigned |      | PRI | NULL                | auto_incre
ment |
| EmployeeID  | text             |      |     |                     |
     |
| DeptID      | int(10) unsigned |      |     | 0                   |
     |
| JobNumber   | text             |      |     |                     |
     |
| TimeElapsed | decimal(10,5)    |      |     | 0.00000             |
     |
| TimeStamp   | datetime         |      |     | 0000-00-00 00:00:00 |
     |
| JobRef      | text             |      |     |                     |
     |
+-------------+------------------+------+-----+---------------------+-----------
-----+
7 rows in set (0.00 sec)

したがって、すべてのクエリが行うことになっているのは、costingjobtimes からすべての行を返すことですが、EmployeeID の代わりに従業員名を、DeptID の代わりに部門の説明を入力します。どんな助けでも素晴らしいでしょう..

前もって感謝します、

4

1 に答える 1

1

インナージョインが本当に帝州を探しているのかわかりません。たぶん、あなたは通常の参加を試みるべきです。

例えば:

select e.Name, d.DeptDesc, j.JobNumber, j.TimeElapsed, j.TimeStamp, j.JobRef
  from costingjobtimes as j
  join costingdepartment as d on d.DeptID = j.DeptId
  join costingemployee as e on e.EmployeeID = j.EmployeeID

これにより、costingjobtimesテーブルの情報と、従業員の名前および部門の説明を組み合わせた結果セットが得られます。

お役に立てば幸いです。

于 2009-11-24T10:54:40.137 に答える