MySql SELECT AS - Append all field names

Posted by jeerose on Stack Overflow See other posts from Stack Overflow or by jeerose
Published on 2010-04-07T18:52:34Z Indexed on 2010/04/08 2:33 UTC
Read the original article Hit count: 321

Filed under:
|

I'd like to do something like this:

SELECT table.id AS prefix_id, table.name AS prefix_name

... and have the prefix added dynamically to all field names rather than selecting them all manually (ie SELECT table.* AS prefix_* or something)

Hopefully I've described that accurately. Any thoughts?

Edit

To be clear, the reason I'm asking is to make sure that my query result contains every column from each table I call even if there are duplicate field names. For example, I might have a table with lots of fields which means I don't want to alias all the fields manually. Further if 3 tables have a field called name my result won't contain three name results; it will have one. I want to avoid ambiguity with my column names.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about mysql-query