Beginning SQL
Beginning SQL Beginning SQL
LastName UPPER(LastName) LOWER(LastName) Hawthorn HAWTHORN hawthorn Gee GEE gee Doors DOORS doors Dales DALES dales Botts BOTTS botts Now that you know how to change a string’s case, the next section looks at how to turn a string backward. The REVERSE() Function The REVERSE() function reverses the order of the characters in a string. For example, ABC becomes CBA. It takes just one argument, the string to be reversed. MS Access calls its REVERSE() function the StrReverse() function, and it works the same. IBM DB2 doesn’t support the REVERSE() function. The following SQL returns LastName and LastName reversed: SELECT LastName, Reverse(LastName) FROM MemberDetails; The results of the query appear in the following table: LastName REVERSE(LastName) Smith htimS Simons snomiS Night thgiN Jones senoJ Jones senoJ Johnson nosnhoJ Jackson noskcaJ Hills slliH Hawthorn nrohtwaH Gee eeG Doors srooD Dales selaD Botts sttoB Manipulating Data 171
- Page 332: Chapter 4 146 Remember, IBM DB2 doe
- Page 336: Chapter 4 148 UPDATE Films SET Film
- Page 340: Chapter 4 150 Finally, you do the s
- Page 344: Chapter 4 152 SELECT * FROM MemberD
- Page 348: Chapter 4 ❑ Choose meaningful nam
- Page 354: 5 Manipulating Data In Chapter 3, y
- Page 358: The results of this query are as fo
- Page 362: You can raise a number to any power
- Page 366: To demonstrate the sort of results
- Page 370: The CEILING() Function The CEILING(
- Page 374: ased on the digits after the decima
- Page 378: The SUBSTRING() function works at t
- Page 384: Chapter 5 The TRIM() Functions Trim
- Page 388: Chapter 5 174 In Oracle and IBM’s
- Page 392: Chapter 5 176 FirstName SOUNDEX(Fir
- Page 396: Chapter 5 Date Functions 178 Someti
- Page 400: Chapter 5 The syntax for the CAST()
- Page 404: Chapter 5 NULLs and Strings 182 NUL
- Page 408: Chapter 5 184 SELECT FirstName, Las
- Page 412: Chapter 5 186 This SQL copies over
- Page 416: Chapter 5 You also learned that mat
- Page 420: Chapter 6 190 Begin by looking at h
- Page 424: Chapter 6 This section covers queri
- Page 428: Chapter 6 194 This query gives the
LastName UPPER(LastName) LOWER(LastName)<br />
Hawthorn HAWTHORN hawthorn<br />
Gee GEE gee<br />
Doors DOORS doors<br />
Dales DALES dales<br />
Botts BOTTS botts<br />
Now that you know how to change a string’s case, the next section looks at how to turn a string backward.<br />
The REVERSE() Function<br />
The REVERSE() function reverses the order of the characters in a string. For example, ABC becomes<br />
CBA. It takes just one argument, the string to be reversed. MS Access calls its REVERSE() function the<br />
StrReverse() function, and it works the same. IBM DB2 doesn’t support the REVERSE() function.<br />
The following <strong>SQL</strong> returns LastName and LastName reversed:<br />
SELECT LastName, Reverse(LastName)<br />
FROM MemberDetails;<br />
The results of the query appear in the following table:<br />
LastName REVERSE(LastName)<br />
Smith htimS<br />
Simons snomiS<br />
Night thgiN<br />
Jones senoJ<br />
Jones senoJ<br />
Johnson nosnhoJ<br />
Jackson noskcaJ<br />
Hills slliH<br />
Hawthorn nrohtwaH<br />
Gee eeG<br />
Doors srooD<br />
Dales selaD<br />
Botts sttoB<br />
Manipulating Data<br />
171