0
我在用下面的查詢麻煩:MySQL查詢,沒有返回什麼,我期望
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行,但放在員工的名字,而不是僱員和部門說明,而不是DEPTID。任何幫助將是巨大的..
由於提前,
謝謝你們。這是更好的方式,但是我發現問題是costingemployee表中缺少一個索引,因此該索引的所有記錄都錯過了。 謝謝 – 2009-11-24 11:20:38