Perl
  Home arrow Perl arrow Page 4 - Creating a Database with Perl and DBI
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PERL

Creating a Database with Perl and DBI
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2008-03-20


    Table of Contents:
  • Creating a Database with Perl and DBI
  • The DESCRIBE Command
  • The INSERT Command
  • The SELECT Command

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Creating a Database with Perl and DBI - The SELECT Command
    ( Page 4 of 4 )

    The SELECT command allows us to query the database, and it reports back to us the information that matches the criteria we specify from the table we indicate. We have seen several SELECT commands in this form:

    mysql> SELECT * FROM musicians; 

     player_id

     name

     phone

     1

     Roger Waters

     555-1212 

     2

     Geddy Lee

     555-2323 

     3

     Marshall Mathers III

     555-3434 

     4

     Thom Yorke

     555-4545 

     5

     Lenny Kravitz

     555-5656 

     6

     Mike Diamond

     555-6767 

     

    6 rows in set (0.00 sec)

    This SELECT asks for * from the table named musicians . The * means “all fields” in the order that they are in the table. We can explicitly ask for the fields by listing them comma separated instead of using the star.

    mysql> SELECT player_id, name, phone FROM musicians;

     player_id

     name

     phone

     1

     Roger Waters

     555-1212 

     2

     Geddy Lee

     555-2323 

     3

     Marshall Mathers III

     555-3434 

     4

     Thom Yorke

     555-4545 

     5

     Lenny Kravitz

     555-5656 

     6

     Mike Diamond

     555-6767 

    6 rows in set (0.01 sec)

    The fields we select can be in any order.

    mysql> SELECT name, phone, player_id FROM musicians;

     name

     phone

     player_id

     Roger Waters

     555-1212 

     1

     Geddy Lee

     555-2323 

     2

     Marshall Mathers III

     555-3434 

     3

     Thom Yorke

     555-4545 

     4

     Lenny Kravitz

     555-5656 

     5

     Mike Diamond

     555-6767 

     6

    6 rows in set (0.00 sec)

    We can request specific fields—we don’t need to show all the fields available.

    mysql> SELECT name, phone FROM musicians;
    +----------------------+----------+
    | name                 | phone    |
    +----------------------+----------+
    | Roger Waters         | 555-1212 |
    | Geddy Lee            | 555-2323 |
    | Marshall Mathers III | 555-3434 |
    | Thom Yorke           | 555-4545 |
    | Lenny Kravitz        | 555-5656 |
    | Mike Diamond         | 555-6767 |
    +----------------------+----------+
    6 rows in set (0.00 sec)

    Please check back next week for the continuation of this article.



     
     
    >>> More Perl Articles          >>> More By Apress Publishing
     

       

    PERL ARTICLES

    - More Perl Bits
    - Perl, Bit by Bit
    - Basic Charting with Perl
    - Using Getopt::Long: More Command Line Option...
    - Command Line Options in Perl: Using Getopt::...
    - Web Access with LWP
    - More Templating Tools for Perl
    - Site Layout with Perl Templating Tools
    - Build a Perl RSS Aggregator with Templating ...
    - Looping, Security, and Templating Tools
    - Perl: Bon Voyage Lists and Hashes
    - Templating Tools
    - Perl: Number Crunching
    - Perl Debuggers in Detail
    - Debugging Perl





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek