Special

Special Print Closeout!

We're clearing out the remainder of our print issues at fire sale prices -- as much as 75% off! Quantities are extremely limited and only available while supplies last. Hurry to take advantage of this one-time offer.

RBD Magazines

Once these printed back issues are gone, they are gone!

Article Preview


Buy Now

Print:
PDF:

Feature

Dealing with Databases

Learning SQL Part 1: The SELECT Statement

Issue: 2.5 (May/June 2004)
Author: Jonathan Johnson
Author Bio: Jonathan Johnson is a Tester for REAL Software. He has done database contract work for two years, and continues to work with databases almost every day.
Article Description: No description available.
Article Length (in bytes): 4,167
Starting Page Number: 25
RBD Number: 2512
Resource File(s): None
Related Link(s): None
Known Limitations: None

Excerpt of article text...

Databases are meant to store information, so one of the most fundamental things SQL must do is be able to query and retrieve data. The SELECT statement does this for you. While it is simple in its structure, it is surprisingly powerful.

The format of the SELECT statement is:

SELECT (field list) FROM (Table Names) [WHERE (conditions)]

The simplest select statement is "SELECT * FROM Customers". The asterisk is used to tell the database that you want every field in the table. The statement, if translated into English, would read: "Select every field from the table Customers, and return them to me."

So, how do we use SQL statements like the one above in REALbasic? The Database class has a method called SQLSelect which returns a RecordSet. A RecordSet is REALbasic's class for dealing with query results. So, to retrieve a last name from the database (assuming a global database variable MyDB):

dim rs as RecordSet

rs = MyDB.SQLSelect("SELECT * FROM Customers")

msgBox rs.field("LastName").StringValue

...End of Excerpt. Please purchase the magazine to read the full article.

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com