SQL获取数据记录号
比如数据库字段中有
name pwd address
ddd ddd dddddd
333 aaa aaaaaa
....
等等
我现在要获取的数据是这样的
1 ddd ddd dddddd
2 333 aaa aaaaaa
也就是说SQL语句执行到处的记录多了一个记录号。
不用自增主键,因为数据可能是我查询得出的,
这样的情况也就是想当于取出数据,给数据重新编号。
希望大家能帮我!!!
谢谢了
[解决办法]
sqlite> create table t1 ( ...> name varchar(10) primary key, ...> pwd varchar(10), ...> address varchar(10) ...> );sqlite>sqlite> insert into t1 values('ddd','ddd','dddddd');sqlite> insert into t1 values('333','aaa','aaaaaa');sqlite>sqlite> select count(*) as rownum,a.name,a.pwd,a.address ...> from t1 a ,t1 b ...> where a.name>=b.name ...> group by a.name,a.pwd,a.address;1|333|aaa|aaaaaa2|ddd|ddd|ddddddsqlite>sqlite> select (select count(*) from t1 where name<=a.name) as rownum,a.* ...> from t1 a ...> order by rownum;1|333|aaa|aaaaaa2|ddd|ddd|dddddd