MySQL database banner

In the process of refactoring some MySQL queries in some PHP code, I came across some interesting syntax for field aliases in the existing code and poked around a bit to see what syntax variations exist.

// basic SELECT syntax
SELECT `field_name` AS columnname FROM `table`;

// alias with a space in the name
SELECT `field_name` AS 'Column Name' FROM `table`;

// AS is optional
SELECT `field_name` 'Column Name' FROM `table`;

By foxbeefly

PHP / MySQL Developer. HTML, CSS and some JavaScript.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.