jdlev has asked for the wisdom of the Perl Monks concerning the following question:

How would I go about selecting 1 complete row of data from a mysql database? For instance, I have 100 rows of data, I just want to pull row #51, how would I do that? Thanks

I love it when a program comes together - jdhannibal
  • Comment on Select Specific Row Of Data From MySQL using DBI?

Replies are listed 'Best First'.
Re: Select Specific Row Of Data From MySQL using DBI?
by jethro (Monsignor) on Jan 20, 2009 at 00:55 UTC
Re: Select Specific Row Of Data From MySQL using DBI?
by Joost (Canon) on Jan 20, 2009 at 01:39 UTC
Re: Select Specific Row Of Data From MySQL using DBI?
by meraxes (Friar) on Jan 20, 2009 at 00:58 UTC

    You may wish to read: How do I post a question effectively?

    Uhhh... kinda vague. This isn't necessarily a Perl question. What have you done? Do you mean you've run a query that returns 100 rows or that you have a table that has 100 rows and you only want one?

    If it's the former, where is the data? In an array? Then you need only reference that element in the array: $rows[50].

    If it's the latter you need to adjust your SQL's WHERE or LIMIT to get only the needed row... not a Perl problem at all.

    --
    meraxes
Re: Select Specific Row Of Data From MySQL using DBI?
by sanku (Beadle) on Jan 20, 2009 at 05:08 UTC
    hi, Use limit command in select statment Example: select * from TABLE_NAME LIMIT 51,1;

      If you do something like select * from TABLE_NAME LIMIT 51,1 you probably want to add an "order by" to that select.

      Would that not be LIMIT 50, 1 because the table rows start at 0? (Assuming the OP is talking about the row in human terms.)

      And you didn't even know bears could type.