[bash]read table


#!/bin/bashmysql


USER="root"sql

PASS="123456"bash

DATABASE="students".net

TABLE="students"get


depts=`mysql -u $USER -p$PASS $DATABASE <<EOF | tail -n +2select

select distinct dept from $TABLE;di

EOF`tar


for d in $depts;

do

        echo Department : $d

        result="`mysql -u $USER -p$PASS $DATABASE <<EOF

        SET @i :=0;

        select @i :=@i+1 as rank,name,mark from $TABLE WHERE dept="$d" order by mark DESC;

EOF`"


echo "$result"

echo


done

相關文章
相關標籤/搜索