将LIMIT添加到查询中

时间:2012-03-04 18:19:55

标签: php mysql join limit

我正在尝试编辑查询并向其添加LIMIT,这需要一段时间。你可以帮我一点吗?

这是工作查询:

$result = mysql_query("SELECT * FROM events INNER JOIN event_performers ON events.ID = event_performers.eventID WHERE event_performers.performerID = '898' ORDER BY events.ID");

我想向其添加LIMIT ' . $offset . ', ' . $rowsPerPage,但收到错误。

提前致谢。

1 个答案:

答案 0 :(得分:1)

限制应该放在最后,比如,“SELECT * FROM your_table LIMIT 0,10”0是偏移量,10是每页行数,可能应该是

mysql_query("SELECT * FROM events INNER JOIN event_performers ON events.ID = event_performers.eventID WHERE event_performers.performerID = '898' ORDER BY events.ID LIMIT ".$offset.", ". $rowsPerPage);