在JAVA中如何编写一个方法同时执行两条SQL文并取得相对应的值?
例如select max(score), name from score_aa
select min(score), name from score_aa
如何同时取得max(score)和min(score)以及他们相对应的name??
初学没多久,请多见谅!谢谢
例如select max(score), name from score_aa
select min(score), name from score_aa
如何同时取得max(score)和min(score)以及他们相对应的name??
初学没多久,请多见谅!谢谢
楼主【darkhrt】截止到2008-07-31 00:36:56的历史汇总数据(不包括此帖):
发帖的总数量:1 发帖的总分数:0 每贴平均分数:0
回帖的总数量:0 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:0 结贴的总分数:0
无满意结贴数:0 无满意结贴分:0
未结的帖子数:1 未结的总分数:0
结贴的百分比:0.00 % 结分的百分比:---------------------
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
取消马甲机器人,请点这里:http://www.java2000.net/mycsdn/robotStop.jsp?usern=darkhrt
mysql:select score,[name] from score_aa
where score in((select score from userinfo order by score desc limit 1),(select score from userinfo order by score limit 1));
sql server:select score,[name] from score_aa
where score in((select top 1 score from userinfo order by score desc),(select top 1 score from userinfo order by score));
select score,[name] from score_aa
where score in((select max(score) from score_aa),(select min(score) from score_aa));
用2个rs对象接收sql语句,然后用2个变量传递值
要是LZ需要函数返回2个值的话,可以用数组:
int max = 你找到的max值;
int min = 你找到的min值;
String[] x = {max+"", min+""};最后
return x;
就可以了
设计数据库时,最好不要用系统变量名