
sql
=
"select
name
from
b1
where
name
like
'"
&
Text2
&
"%'"
'
order
by
name"
这只是查询出一个字段出来吧,换成就可以出全表的数据了,不知道你问的是这个吗?
这个时候得用游标了。比如:
create proc cursorTest @_id int=0, @_name varchar(50)='' as --创建游标 declare @cursor cursor --设定游标欲 *** 作的数据集 set @cursor=cursor for select _id,_name from users --打开游标 open @cursor --移动游标指向到第一条数据,提取第一条数据存放在变量中 fetch next from @cursor into @_id,@_name --如果上一次 *** 作成功则继续循环 while(@@fetch_status=0)begin -- *** 作提出的数据 print @_name --继续提下一行 fetch next from @cursor into @_id,@_name end --关闭游标 close @cursor --删除游标 deallocate @curso
List<CatchDate> abc =daoqueryBySQL
//如果你只要ID
List<String> list =new ArrayList<String>();
for(CatchDate cd:abc){
listadd(cdgetCategoryid());
}
return list;
完全可以的,你不想用while循环也完全可以做到。
我给你大致说一下思路:
打开数据库获得记录集,之后按要求定义二维数组
假定数组为:MM_Array(X,Y)
那么,X指定字段,Y指定记录。
用两个For循环嵌套,就可以把Y条记录(每条记录取前X字段)的值存到数组中了。
……PS:为什么While循环不是很好?用好了哪个都一样。
创建一个存储过程用来读取
create
procedure
testpercudure
as
declare
@col
integer
declare
@tablename
varchar(100)
declare
@sql
as
varchar(200)
begin
select
top
0
qqnum
into
dboqqnum
from
groupdatadbogroup001
--创建一个表用来装你的数据
set
@col=1
set
@tablename='st'
while
@db_num<=100
begin
set
@sql='select
from
'+@tablename+@col+'
group'+'
where
sname
=
'李三''
--通过循环获取你的表名和数据库名,之后组装成sql语句,然后执行你试试
我没数据库不好修改的
execute
sp_executesql
@sql
set
@col=@col+1
set
@col=1
end
end
大概像上面的存储过程一样,这样要求表名是st1,st2,
,st100
以上就是关于怎么用sql语句查找所有数据库表的数据全部的内容,包括:怎么用sql语句查找所有数据库表的数据、查询数据库时,如何循环显示出所有数据、Java用sql在数据库循抓出数据,然后循环接收数据中的字段等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)