Using Functions

Most of the functions you’ll learn in this chapter are used with SQL queries to format and alter the returned data. To use any function, you need to modify your query so that you specify to which column or columns the function should be applied.

SELECT FUNCTION(column) FROM tablename;

To specify multiple columns, you can write a query like either of these:

  • SELECT *, FUNCTION(column) FROM tablename;

  • SELECT column1, FUNCTION(column2), column3 FROM tablename;

While the function names themselves are case-insensitive, I will continue to write them in an all-capitalized format, to help distinguish them from table and column names (as I also capitalize SQL terms). One important rule with functions is that you cannot have spaces between ...

Get PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.