想了許久,發現可以用mysql的變數解決,
於是我給出了於下答案。
set @i := 0;
select concat(@i := @i + 1,』.』,title) astitle
,type
from (select 『a』 title, 1 type from dual union all
select 『b』 title, 1 type from dual union all
select 『c』 title, 1 type from dual union all
select 『d』 title, 2 type from dual union all
select 『e』 title, 2 type from dual) a
where type=1
order by title asc;
set @i := 0;
select concat(@i := @i + 1,』.』,title) astitle
,type
from (select 『a』 title, 1 type from dual union all
select 『b』 title, 1 type from dual union all
select 『c』 title, 1 type from dual union all
select 『d』 title, 2 type from dual union all
select 『e』 title, 2 type from dual) a
where type=2
order by title asc;
還有個問題是如何將兩個結果集合並為一,暫時還沒發現,暫時擱置。
SQL給查詢結果加序號
情境 在用delphi7程式設計時,想要給查詢出的結果乙個編號,比方有一萬條結果,就自己主動從1編號到10000 顯示資料時用的是dbgrid控制項,可是它的第一列無法非常好的顯示編號,找了非常多方法都不能如願 後又選用stringgrid,自己在第一列顯示序號,效果達到了,可是卻沒有dbgrid速...
Mysql 給查詢出的結果集新增自增序號
模板如下 select rownum rownum 1 自增序號別名,結果集欄位 from 結果集,select rownum 0 as 任意別名示例如下 select rownum rownum 1 as rownum,a.from select u.from users u order by u...
mysql 查詢結果中自動加序號列
查詢mysql 資料庫 自動 新增 序號 欄位列1,2,3,4.就像這樣。select rowno rowno 1 as rowno,zhuanfacontent,content,senddate,sendtime,zhuanfaauthor,zhuanfalink from select zhua...