我得到以下查询,它也很好。
SELECT date, duration, educationDepartment, yearOfTraining, completedtasks
FROM programm_completedtask
WHERE date BETWEEN '2014-08-05' AND '2014-08-08'
AND trainee_id =
(SELECT id FROM programm_trainee WHERE username = 'Markus');
除了第二个select语句,还有其他可能要做的事情吗?我只想选择一次。
最佳答案
使用内连接...
SELECT p.date, p.duration, p.educationDepartment, p.yearOfTraining, p.completedtasks
FROM programm_completedtask as p
INNER JOIN programm_trainee as pt on p.trainee_id = pt.id AND pt.username = 'Markus'
WHERE p.date BETWEEN '2014-08-05' AND '2014-08-08'
要么
SELECT p.date, p.duration, p.educationDepartment, p.yearOfTraining, p.completedtasks
FROM programm_completedtask as p
INNER JOIN programm_trainee as pt on p.trainee_id = pt.id
WHERE p.date BETWEEN '2014-08-05' AND '2014-08-08'
AND pt.username = 'Markus'
关于mysql - 溶解第二条选择语句,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25206295/