Get MySQL database column names (with table name) using Coldfusion

I hope someone helps me, as it made me scratch my head.

Since most of them already know about 2 easy ways to get mysql query column names using coldfusion:

1. <cfset arrColumns = ListToArray(thequery.columnList) />
2. <cfset arrColumns = getMetaData(thequery) />

both of them will successfully create an array of column names (1 in alphanumeric order, 2 in the order received from the database).

For example:

<cfquery name="thequery" datasource="thedatasource">
    SELECT a.title, b.name 
    FROM tablea a
    JOIN tableb b ON b.a_id = a.id
</cfquery>
<cfset arrColumns = ListToArray(thequery.columnList) />

The above option will successfully return an array with the values:

arrColumns[1]: "name" 
arrColumns[2]: "title"

I need to do this:

arrColumns[1]: "tableb.name" 
arrColumns[2]: "tablea.title"

... basically, to include the database table name along with the column name. This made me scratch my head for some time, and any help would be greatly appreciated. I already searched Google and stackoverflow and did not find the answers.

thanks

+4
2

, JDBC (getTableName()) ColdFusion . , , , , .

, , -. , , , ... .

+1

. , . , , . - :

select table1.field1 "table1.field1"
, table1.field2 "table1.field2"
etc
0

All Articles