QA


Q&A

Q

What characters can I use to name my tables and fields, and what is the character limit?

A

The maximum length of database, table, or field names is 64 characters. Any character that you can use in a directory name or file name, you can use in database and table namesexcept / and .. These limitations are in place because MySQL creates directories and files in your file system, which correspond to database and table names. There are no character limitations (besides length) in field names.

Q

Can I use multiple functions in one statement, such as making a concatenated string all uppercase?

A

Surejust be mindful of your opening and closing parentheses. This example shows how to uppercase the concatenated first and last names from the master name table:

 mysql> SELECT UCASE(CONCAT_WS(' ', firstname, lastname)) FROM table_name; +--------------------------------------------+ | UCASE(CONCAT_WS(' ', firstname, lastname)) | +--------------------------------------------+ | JOHN SMITH                                 | | JANE SMITH                                 | | JIMBO JONES                                | | ANDY SMITH                                 | | CHRIS JONES                                | | ANNA BELL                                  | | JIMMY CARR                                 | | ALBERT SMITH                               | | JOHN DOE                                   | +--------------------------------------------+ 9 rows in set (0.00 sec) 

If you want to uppercase just the last name, use

 mysql> SELECT CONCAT_WS(' ', firstname, UCASE(lastname)) FROM master_name; +--------------------------------------------+ | CONCAT_WS(' ', firstname, UCASE(lastname)) | +--------------------------------------------+ | John SMITH                                 | | Jane SMITH                                 | | Jimbo JONES                                | | Andy SMITH                                 | | Chris JONES                                | | Anna BELL                                  | | Jimmy CARR                                 | | Albert SMITH                               | | John DOE                                   | +--------------------------------------------+ 9 rows in set (0.00 sec) 



Sams Teach Yourself PHP MySQL and Apache All in One
Sams Teach Yourself PHP, MySQL and Apache All in One (4th Edition)
ISBN: 067232976X
EAN: 2147483647
Year: 2003
Pages: 333
Authors: Julie Meloni

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