gpt4 book ai didi

sql - 如何将 SQL 数据顺序从行更改为列?

转载 作者:行者123 更新时间:2023-12-01 02:42:45 25 4
gpt4 key购买 nike

我有一段代码可以按字母顺序从数据库跨 3 列写入网页上的数据。

例子:

a result   b result  c resultd result   e result  f resultg result   h result  i result

I need instead to display it alphabetically DOWN the columns, like this:

a result   d result  g resultb result   e result  h resultc result   f result  i result

Keeping in mind I have about 100 data results, it would display the first 1/3 in column one descending, then start a new column and continue, breaking it into 3 equal parts.

The code I have now that sorts across the rows is:

<% 
GL="<table width="+Z+"100%"+Z+"border=0 cellpadding=3 celspacing=3>"
sql="select * from guideDef order by guideDesc;"
rs.open sql,adoCon
colCount=0
do while not rs.eof
colCount=(colCount+1) mod 3
if colCount=1 then GL=GL+"<tr>"
GL=GL+"<td valign=middle id=menu1 width="+Z+"33%"+Z+">"+E
GL=GL+"<a href="+Z+"shop.asp?guide="+rs("guide")+"&city=Plantation"+Z+">"+E
GL=GL+rs("guideDesc")+"</a></td>"
if colCount=0 then GL=GL+"</tr>"
GL=GL+E
rs.moveNext
loop
rs.close
if colCount=1 then GL=GL+"<td> </td><td> </td></tr>"+E
if colCount=2 then GL=GL+"<td> </td></tr>"+E
GL=GL+"</table>"
response.write GL
%>

在此先感谢您的帮助。我不写代码,所以我尝试了几个小时来改变它,但没有成功。

最佳答案

也许更好的解决方案是保留 SQL 并在应用程序代码中处理它,而不是作为查询的结果。

关于sql - 如何将 SQL 数据顺序从行更改为列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/562177/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com