Database Articles
  Home arrow Database Articles arrow Page 3 - Databases and SQL
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
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? 
DATABASE ARTICLES

Databases and SQL
By: bluephoenix
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2004-04-19

    Table of Contents:
  • Databases and SQL
  • Adding Information To A Database
  • Retrieving Information From A Database
  • Changing Information In A Database
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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


    Databases and SQL - Retrieving Information From A Database


    (Page 3 of 5 )

    It wouldn't make sense to save information without the ability to retrieve it at some future date. The SELECT command is used to retrieve records from a table.

    The SELECT statement is both powerful and flexible. But because this is an introductory tutorial, all of the nuances of the SELECT command won't be covered. I'll instead illustrate the basic usage of the command.

    A simple form of the SELECT command is SELECT followed by the desired field to retrieve, FROM and then followed by the desired table. An asterisk can be used as shorthand to request all fields.

    SELECT * FROM addresses;

    The results of such a query might resemble our initial table example.

    Last Name  First Name  Address             City       State  Zip Code
    ---------------------------------------------------------------------
    Adams      Gwendolyn    205 W Third St.    Brownville AL     35020
    Johnson    Diane        82 Richardson Ave. Fresno     CA     93702
    Smith      Harold      321 Elm St.         Portsmouth RI     02871

    Of course returning every record might not be desired. The keyword WHERE may be used to set forth conditions to satisfy when selecting matching records.

    SELECT * FROM addresses WHERE state = "CA";

    Such a query would return only the records where the abbreviation for California appears in the state field.

    Last Name  First Name  Address             City    State  Zip Code
    ------------------------------------------------------------------
    Johnson    Diane        82 Richardson Ave. Fresno  CA     93702

    AND and OR may also be used to identify more than one field when constructing a WHERE condition.

    SELECT * FROM employees WHERE first_name = "Diane" AND
    last_name = "Johnson";

    Such a query would return only the records where the value of first_name is Diane and the value of last_name is Johnson.

    ID   First Name  Last Name  Date Hired  Notes
    -----------------------------------------------------------------------
    189  Diane       Johnson    2001-07-15  secretary of the year for 2003

    As mentioned earlier, the asterisk is a shorthand request for all fields. Individual fields may be requested by listing them after SELECT. Commas separate multiple requested fields.

    SELECT first_name, last_name FROM addresses;

    Such a query would return just the values of the first_name and last_name fields in the address table.

    First Name  Last Name
    ---------------------
    Gwendolyn   Adams
    Diane       Johnson
    Harold      Smith

    More Database Articles Articles
    More By bluephoenix


       · Hi,how can i make severals updates at the same time (nmaybe using while)i...
       · Like most other queries, UPDATE affects all of a table's rows unless you specify...
       · Please, can you help me. I'm very new beginer in php :)There's my problem. I know...
     

    DATABASE ARTICLES ARTICLES

    - More on Query Optimization for Oracle Databa...
    - Query Optimization in Oracle
    - Clusters and Other Data Structures for Oracle
    - Using Indexes with an Oracle Database
    - The Basics of Data Structures in Oracle
    - Oracle Data Structures
    - Best Practices for PL/SQL Variables
    - What`s Code Without Variables?
    - Clauses, Sorting, and SQL Queries
    - The From Clause and SQL Queries
    - Query Primer
    - Full Text Searches and Strings
    - Searching with Strings
    - Pattern Matching with Strings
    - Working with Cases of Strings





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