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

I'm slowly but surely picking up database managment by perl. So far I can connect, disconnect, insert, and select items from a mysql database.

My next step is to locate specific things in a table in mysql. Here's what I want to do. I want to take one row of data, compare it with another row of data by using certain mathematcial equations, and return that data to some place. How would I go about doing that? Thanks, Jeff

I love it when a program comes together - jdhannibal

Replies are listed 'Best First'.
Re: DBI for noobs
by tilly (Archbishop) on Jan 08, 2009 at 06:43 UTC
    Depends on the mathematical equations. You could write the math in SQL. Or you could fetch the data into your favorite programming language, do the equations, and then insert into another table.

    The bigger question is whether you know how to pair up your rows in whatever way you desire. To do that you likely need to know how to write a join. this explains the syntax reasonably well.

      I would like to do the equations outside of SQL

      I love it when a program comes together - jdhannibal
Re: DBI for noobs
by roboticus (Chancellor) on Jan 08, 2009 at 12:47 UTC
Re: DBI for noobs
by graff (Chancellor) on Jan 09, 2009 at 03:52 UTC
    I want to take one row of data, compare it with another row of data by using certain mathematcial equations, and return that data to some place. How would I go about doing that?

    Well, given that amount of information about the task, along with the amount of sample input data, intended output data and attempted code you've given us, I think the way you'd go about it is:

    - select one row of data somehow - select another row of data (either in the same way, or differently +) - do some arithmetic on the two pieces of data and compare the resul +ts - Insert or otherwise store some suitable result data somewhere
    Perhaps that wasn't very helpful, but it's the best I could do with what I know.

    How about you try something out, and if it works, great! If it doesn't, show us the code you tried, what data went into it, what it produced, and how that differed from what you wanted. (Or, if all you get is error messages, show the code and the error messages.)