1. 程式人生 > >mysql聯表查詢腳本

mysql聯表查詢腳本

mysql聯表查詢腳本

mysql聯表查詢腳本:

#!/bin/sh
kkmailmysqlpass=$(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.txt
awk '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.txt
cat user2.txt |sed 1d | sed '1i\姓名    郵箱    容量    網盤    發送    接收    職位    部門' >/root/user3.txt


mysql聯表查詢腳本