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 similarly. Consider the following data that could appear in the Employees table:
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 appends the FirstName and LastName fields together. The query would look like this: SELECT EmployeeID, FirstName & LastName AS Name FROM Employees Notice the & operator. The & operator is used to concatenate, or join, two fields into one virtual field using the AS keyword. The results would display as follows:
Notice that there is no space between the first and last names. To add a space, you need to add a literal string value as follows: SELECT EmployeeID, FirstName & ' ' & LastName AS Name FROM Employees NOTE You might have noticed that we've been using single quotes in every SQL statement. The reason for this is simple: When you construct your SQL statements in Dreamweaver, the server-side language encloses the entire statement in double quotes. For the statement to be valid, strings within a SQL statement must be enclosed within single quotes. Adding the space results in a gap between the first and last names as follows:
|