添加LIMIT时,INNER JOIN不起作用

时间:2010-11-09 15:46:30

标签: mysql limit inner-join

好的,这是我正在使用的代码并且工作得很好:

$curEvent_query = @mysql_query("SELECT ppl.Fname, ppl.Lname, ppl.Email, plans.ID, plans.Date FROM ppl INNER JOIN plans ON plans.ID IN ($List) AND plans.OwnerID=ppl.ID AND plans.Date >= CURDATE() ORDER BY plans.Date ASC");

但是一旦我添加了LIMIT,代码就不再起作用了:

$curEvent_query = @mysql_query("SELECT ppl.Fname, ppl.Lname, ppl.Email, plans.ID, plans.Date FROM ppl INNER JOIN plans ON plans.ID IN ($List) AND plans.OwnerID=ppl.ID AND plans.Date >= CURDATE() ORDER BY plans.Date ASC LIMIT $offset, $rowsPerPage");

添加LIMIT的原因是因为我想进行分页。我有什么想法我做错了吗?需要帮助asap!

1 个答案:

答案 0 :(得分:0)

请添加输出:

$query = "SELECT ppl.Fname, ppl.Lname, ppl.Email, plans.ID, plans.Date FROM ppl INNER JOIN plans ON plans.ID IN ($List) AND plans.OwnerID=ppl.ID AND plans.Date >= CURDATE() ORDER BY plans.Date ASC LIMIT $offset, $rowsPerPage";
echo $query;
$curEvent_query = mysql_query($query);
if (!$curEvent_query)
    echo mysql_error();