能否一次取出两类记录,而不用分两次取出

[复制链接]
查看11 | 回复4 | 2010-5-21 11:22:36 | 显示全部楼层 |阅读模式
我的一个数据库student 中有id name fid beizhu
四个字段
id namefid 备注
1 张三
1 好
2 张三1 1 好
3 张三2 1 好
4 张三3 1 好
5 张三4 2 好
6 张三5 2 好
7 张三6 2 好
8 张三7 2 好
9 张三8 3 好
我要取出fid为1和2的记录,现在方法就是分两次取,
select * from student where fid=‘“+1+”’;
select * from student where fid=‘“+2+”’;

能否一次取出,sql语句咋写,还是不能实现。望高手指点。
shutao917 你好:照你说的能够全部显示出来,能不能分类显示,现在rs.getString(1)是全显示,能否 分别显示fid为1,fid为2在两个地方,并不是笼统的把他们 都显示在一个地方。以前我是在两个需要显示的地方两次查询,再显示。现在能否一次查询 ,分别在两个地方显示引用。

回复

使用道具 举报

千问 | 2010-5-21 11:22:36 | 显示全部楼层
select * from student where fid in(1,2)
回复

使用道具 举报

千问 | 2010-5-21 11:22:36 | 显示全部楼层
select * from student where fid='1' or fid='2' 那你就点一个按钮,执行两个SQL语句,把两天查询语句查出的数据分别赋值给两个显示的地方
回复

使用道具 举报

千问 | 2010-5-21 11:22:36 | 显示全部楼层
select * from student where fid=‘“+1+”’;select * from student where fid=‘“+2+”’;===》select * from student where fid=‘“+1+”’or fid=‘“+2+”’;
回复

使用道具 举报

千问 | 2010-5-21 11:22:36 | 显示全部楼层
select * from student where fid0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行