60

mysql联表查询脚本-赛里-51CTO博客

 6 years ago
source link: http://blog.51cto.com/net881004/2072698
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

share_default.jpg

赛里 > shell > 正文

mysql联表查询脚本

mysql联表查询脚本:

#!/bin/shkkmailmysqlpass=$(cat /usr/local/kk-mail/config/custom.conf | grep -w "pass" | awk -F" " '{print $NF}')/usr/local/kk-mail/service/mysql/bin/mysql -u kkmail -p$kkmailmysqlpass kkmail -e "select b.realname,a.mailbox,a.quota_mailbox,a.quota_netdisk,a.limit_send,a.limit_recv,c.position,d.title from core_mailbox a,co_user b,co_department_member c,co_department d where a.mailbox_id=b.mailbox_id and a.mailbox_id=c.mailbox_id and c.dept_id=d.id;" >/root/user.txtawk 'BEGIN{OFS="\t"} {if($5==-1){$5="不限制"}if($5==1){$5="禁止"}if($5==2){$5="本域"}if($5==3){$5="指定外域"}if($5==4){$5="本地所有域"}if($6==-1){$6="不限制"}if($6==1){$6="禁止"}if($6==2){$6="本域"}if($6==3){$6="指定外域"}if($6==4){$6="本地所有域"}print}' /root/user.txt >/root/user2.txtcat user2.txt |sed 1d | sed '1i\姓名    邮箱    容量    网盘    发送    接收    职位    部门' >/root/user3.txt



About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK