I would like to rename the columns in the results of a SELECT
expression. Of course, the following doesn't work:
SELECT * AS foobar_* FROM `foobar`
As I'm new to SQL, I think I'm just missing a concept, tool, or keyword that would lead to the answer. A hint in the right direction would be appreciated. Thanks!
UPDATE
I'm looking for a generic way to do this, and MySQL-specific techniques are absolutely fine.
In short, I'm writing a tool that "exports" the results of MySQL queries to Google Spreadsheets (via the Google Data API). Some queries are joins, so to make columns unique I wanted to prefix all column names with their respective table names.
SELECT col1 As Foo, col2 As Bar FROM foobar
. By the way: Don't use "SELECT*" in a SQL query. Unnecessary columns may get fetched that will add expense to the data retrieval time. The database engine cannot utilize the benefit of "Covered Index" and hence the query performs slowly.