See DBI and the (SQL?) documentation that came with your database software.
If you need additional help figuring out with the syntax of the database command to do what you want, contact your database vendor's technical support department. If you need additional help building a Perl solution, by all means give us more information in a post to Seekers of Perl Wisdom.