Mohit Jain
Mohit Jain

Reputation: 43949

How can i get in between rows in mysql query

I want to fetch intermediate rows from by database.

Like for last 10 rows i will use limit :

    return Doctrine_Query::create()
                ->select('v.*')
                ->from('Video v')                   
                ->where("v.community_id='$community_id' AND v.user_id='$user_id' AND v.published='$published'")
                ->orderBy('v.id DESC')
                ->limit(10)
                ->execute();        

but what if i want 110-120 rows?Can anybody tell me about that? how to write this kind of query in doctrine

Upvotes: 0

Views: 294

Answers (4)

Mohit Jain
Mohit Jain

Reputation: 43949

use offset clause...chk dis

Upvotes: 0

Marek Karbarz
Marek Karbarz

Reputation: 29304

You could use a Doctrine_Pager

$page = 10;
$limit = 10;
$query = Doctrine_Query::create()
        ->select('t.*')
        ->from('SomeTable t')

$pager = new Doctrine_Pager(
    $query,
    $page,
    $limit
);

$rows = $pager->execute();

Upvotes: 3

Jenni
Jenni

Reputation: 1706

For rows 110-120, you want

LIMIT 109, 10

Upvotes: 1

AJ.
AJ.

Reputation: 28184

Use the offset() clause.

Upvotes: 4

Related Questions