在JAVA中如何编写一个方法同时执行两条SQL文并取得相对应的值?
例如select max(score), name from score_aa
    select min(score), name from score_aa
如何同时取得max(score)和min(score)以及他们相对应的name??
初学没多久,请多见谅!谢谢

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【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
      

  2.   

    select max(score),min(score), name from score_aa group by name
      

  3.   

    试了一下2楼的代码,将会查出所有数据下面的能达到要求
    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));
      

  4.   

    刚才想复杂了,下面的就可以了
    select score,[name] from score_aa
    where score in((select max(score) from score_aa),(select min(score) from score_aa));
      

  5.   

    可以这样
    用2个rs对象接收sql语句,然后用2个变量传递值
    要是LZ需要函数返回2个值的话,可以用数组:
    int max = 你找到的max值;
    int min = 你找到的min值;
    String[] x = {max+"", min+""};最后
    return x;
    就可以了
      

  6.   

    再请教下,[name]是什么意思?
      

  7.   

    name和系统变量冲突,所以加[]区分
    设计数据库时,最好不要用系统变量名
      

  8.   

    select score,name from score_aa where score in ((elece max(score) from score_aa),(elece max(score) from score_aa))