Skip to main content
March 11, 2008
Question

Rename columns within a query?

  • March 11, 2008
  • 1 reply
  • 568 views
Is there a way that I can rename a column within a coldfusion query? I've attached an example.

I've joined a table with the same table here and have named them A and B. I want to be able to rename the columns in B so that, when I display the output, they do not have the same names as in A. (Eg. b_pkgname and b_pkgrev).
This topic has been closed for replies.

1 reply

Inspiring
March 11, 2008
Brandi L wrote:
> Is there a way that I can rename a column within a coldfusion query?

Yup and in any other technology making use of SQL that supports the
alias 'AS' statement.

I.E.

SELECT
a.site,
a.pkgname,
a.pkgrev,
b.pkgname AS b_pkgname,
b.pkgrev AS b_bkgrev
...


I hear good things about Ben Forta's "Teach Yourself SQL in 10 Minutes"
as well as the many SQL references and tutorials available on the internets.

March 12, 2008
Thanks for the assistance! I learned a little SQL in school but I'm definitely rusty. Its funny - I googled this and couldn't find the answer I was looking for. I'll check out Forta's tutorial. :)