Expression

Team-Fly    

Macromedia® DreamWeaver® MX Unleashed
By Matthew Pizzi, Zak Ruvalcaba
Table of Contents
Chapter 27.  SQL Primer


If you are the least bit familiar with programming languages, you know that expressions are anything that, when calculated, result in a value. For instance, 1 + 1 = 2 is an example of an expression. Expressions in SQL work much the same way. Consider the following data from the customers table:

CustomerID FirstName LastName
1 Zak Ruvalcaba
2 David Levinson
3 Matthew Pizzi
4 Jessica Ruvalcaba

You could use a simple Select statement to display the information exactly as it appears in the preceding table, or you could write an expression that concatenates the FirstName and LastName fields. The query would look like this:

 Select CustomerID, FirstName & LastName As Name From Customers  

Notice the "&" operator. The "&" operator is used to concatenate or join together two fields into one virtual field using the As keyword. The results would display as follows:

CustomerID Name
1 ZakRuvalcaba
2 DavidLevinson
3 MatthewPizzi
4 JessicaRuvalcaba

Notice that there is no space between the first and last names. To add a space, you need to add a literal string value:

 Select CustomerID, FirstName & ' ' & LastName As Name From Customers  

Adding the space results in spaces between the first and last names:

CustomerID Name
1 Zak Ruvalcaba
2 David Levinson
3 Matthew Pizzi
4 Jessica Ruvalcaba


    Team-Fly    
    Top


    Macromedia Dreamweaver MX Unleashed
    Macromedia Dreamweaver MX 2004 Unleashed
    ISBN: 0672326310
    EAN: 2147483647
    Year: 2002
    Pages: 321

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net