我有以下查询,在其他用户想要生成报告之前工作正常。该查询提供了所有信息,但不是用户特定的信息。这让我感到困惑,因为当我在我的数据库中执行查询时,查询完全正常。
SELECT date, duration, educationDepartment, completedtasks FROM
programm_completedtask WHERE date BETWEEN $P{Startdatum} AND
$P{Enddatum} AND trainee_id = (SELECT id FROM programm_trainee WHERE
username = $P{username});
我的 programm_completedtask 看起来像这样
+------------------------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+----------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| trainee_id | int(11) | NO | MUL | NULL | |
| date | date | NO | | NULL | |
| duration | int(11) | NO | | NULL | |
| documentationReference | longtext | YES | | NULL | |
| educationDepartment | longtext | YES | | NULL | |
| completedtasks | longtext | NO | | NULL | |
+------------------------+----------+------+-----+---------+----------------+
我的 programm_trainee看起来就像这样
+--------------------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+----------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| comment | longtext | YES | | NULL | |
| firstName | longtext | NO | | NULL | |
| lastName | longtext | NO | | NULL | |
| educationBeginning | date | NO | | NULL | |
| username | longtext | NO | | NULL | |
+--------------------+----------+------+-----+---------+----------------+
你有什么建议为什么这对我不起作用?
答案 0 :(得分:0)
我使用了INNER JOIN
而不是第二个SELECT
语句,现在可以使用了。