我有两张桌子,
第一个表格:tasktable
,其中包含以下列:
第二个表:projecttable
包含列:
现在我尝试使用join查询这两个表并获取
的所有详细信息taskid,user,projectname for the following condition
currentdate > startdate and remainingduration > 0
有些人可以帮我解决这个问题。
由于
答案 0 :(得分:1)
只需加入projectid
select taskid,user,projectname
from tasktable
join projecttable on projecttable.projectid= tasktable.projectid
where CURDATE() > startdate and remainingduration > 0
希望startdate列是dateformat
答案 1 :(得分:0)
此语句为您提供所需的结果。
SELECT taskid, user, projectname FROM tasktable
INNER JOIN projecttable ON tasktable.projectid = projecttable.projectid
WHERE currentdate > startdate AND remainingduration > 0
答案 2 :(得分:0)
Select t1.taskid, t1.user, t2.projectname
from tasktable t1 join projecttable t2 ON (t1.projectid = t2.projectid)
where currentday > startdate and t1.remainingduration > 0
order by t1.taskid
答案 3 :(得分:0)
试试这个:
SELECT * FROM projecttable INNER JOIN tasktable ON
tasktable.projectid = projecttable.projectid AND GETDATE() > startdate
AND remainingduration > 0
您可以在连接条件
中添加条件