我在我的选择语句中选择了两次 State 和 Zip3 列,准确地说明了我想看到的内容。当我在本机 MySQL 中执行此操作时,我得到了正确的结果:
SELECT State,Zip3, FirstName, LastName, State, Zip3
FROM Person
WHERE State >= 'A'
ORDER BY State, Zip3
LIMIT 10;
+-------+------+-----------+-------------+-------+------+
| State | Zip3 | FirstName | LastName | State | Zip3 |
+-------+------+-----------+-------------+-------+------+
| AB | T7X | Adalei | Starreveld | AB | T7X |
| AK | 998 | Linda | Rosenthal | AK | 998 |
| AL | 361 | Benjamin | Sung | AL | 361 |
| AL | 362 | Lawrence | Kallus | AL | 362 |
| AZ | 857 | Rose | Springfield | AZ | 857 |
| CA | 941 | Maura | Cronin | CA | 941 |
| CA | 941 | Dov | Grunschlag | CA | 941 |
| CA | 943 | Ruth | Hodos | CA | 943 |
| CT | 055 | Andrew | Salvo | CT | 055 |
| CT | 064 | DEBORAH | GRASER | CT | 064 |
+-------+------+-----------+-------------+-------+------+
当我在 Cold Fusion 中执行此操作时,我得到了错误的结果:
<cfquery name = "stest" datasource = "Moxart">
select State,Zip3, FirstName,LastName,State,Zip3 from Person
where State >= 'A'
order by State,Zip3
</cfquery>
<cfset j = 0>
<table>
<cfoutput query = "stest">
<tr>
<cfloop index = "col" list = "#columnlist#">
<cfset j = j + 1>
<cfset colname[j] = #stest[col][currentrow]#>
<td> #colname[j]# </td>
</cfloop><br/>
</tr>
</cfoutput>
</table>
Adalei Starreveld AB AB T7X T7X
Linda Rosenthal AK AK 998 998
Benjamin Sung AL AL 361 361
Lawrence Kallas AL AL 362 362
Rose Springfield AZ AZ 857 857
Maura Cronin CA CA 941 941
Dov Grunschlag CA CA 941 941
Ruth Hodos CA CA 943 943
Andrew Salvo CT CT 055 055
DEBORAH GRASER CT CT 064 064
如何从 ColdFusion 中获得正确的结果。我正在使用 ColdFusion 8 和 Firefox。