如何使用where for mysql和php启动有限查询?
例如,以下查询??
$start = 0;
$range = 10;
$query = "SELECT column FROM $table LIMIT $start, $range";
但我想做的是从特定列值开始限制$ start并从那里开始增加,如下所示:
$start = column_value;
答案 0 :(得分:3)
将where子句添加到SQL查询中:
$query = "SELECT column
FROM $table
WHERE column >= $column_value
LIMIT $start, $range";
答案 1 :(得分:0)
您也需要一个ORDER BY子句。
$query = "SELECT column
FROM $table
WHERE column > $column_value
ORDER BY column
LIMIT $start, $range";