我在mySQL中有以下复杂查询
SELECT courseId,courseName
FROM course WHERE courseId NOT IN (SELECT courseId FROM coursestaken NATURAL JOIN student WHERE grade >= 60 AND studentId =2)
AND
courseId NOT IN (SELECT courseId FROM stable WHERE studentId = 2 )
AND
courseId NOT IN (SELECT DISTINCT courseId FROM prerequisites
WHERE
prereqId NOT IN (SELECT courseId FROM coursestaken NATURAL JOIN student WHERE grade >= 60 AND studentId =2 )) ;
有人可以帮我将其转换为Propel中的Criteria()查询吗?
答案 0 :(得分:4)
尝试在下面的推进中使用prepare函数
$con=Propel::getConnection();
$obj = $con->prepare("SELECT courseId,courseName
FROM course WHERE courseId NOT IN (SELECT courseId FROM coursestaken NATURAL JOIN student WHERE grade >= 60 AND studentId =2)
AND
courseId NOT IN (SELECT courseId FROM stable WHERE studentId = 2 )
AND
courseId NOT IN (SELECT DISTINCT courseId FROM prerequisites
WHERE
prereqId NOT IN (SELECT courseId FROM coursestaken NATURAL JOIN student WHERE grade >= 60 AND studentId =2 )) ");
$obj->execute();
$resultset = $obj->fetchAll();