Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: DBI - retrieving a specific row

by Trimbach (Curate)
on Feb 04, 2002 at 13:27 UTC ( [id://143228]=note: print w/replies, xml ) Need Help??


in reply to DBI - retrieving a specific row

If all you want is a specific row from the database you can do something like this:
my $sth=$dbh->prepare("SELECT * FROM my_table WHERE primary_key = ?"); $sth->execute(4); my @record = $sth->fetchrow();
It's really no big deal, and doesn't require any freaky LIMIT or anything like that. Of course, this assumes that your SELECT will only return one row (which it will, if you're SELECTing from a Primary Key).

Update:Whoops. Misunderstood what the poster wanted. Ah well... hakkr's post has what you want.

Gary Blackburn
Trained Killer

Replies are listed 'Best First'.
Re: Re: DBI - retrieving a specific row
by S_Shrum (Pilgrim) on Feb 07, 2002 at 11:32 UTC

    Let's take it a step further.

    Let's say I have a group of records and I want to do a data slice. What I mean by this is say I have 50 records but I only want to display 10 records at a time. Say then I indicate I want slice 3; I would be viewing records 21-30 (1=1-10, 2=11-20, ...).

    Is it possible to make a query call to the DBI that would allow for this sort of functionality? LIMIT seemed like the way to go but it appears that LIMIT is not supported in SQL::Statement.

    ======================
    Sean Shrum
    http://www.shrum.net

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://143228]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2025-04-20 09:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.