As @Pierre notes, the name you want is in name2. If you want to get BED format from the SQL, you can use something like:
ORG=$1
#mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A -D $ORG -P 3306 -e "select chrom,txStart,txEnd,name2 as name,strand,exonStarts,exonEnds from refGene;" > $ORG.notbed
awk '
BEGIN { OFS = "\t"; FS = "\t"} ;
(NR != 1){
delete astarts; delete aends;
split($6, astarts, ",");
split($7, aends, ",");
starts=""; sizes=""
exonCount=0
for(i=1; i <= length(astarts); i++){
if (! astarts[i]) continue
sizes=sizes""(aends[i] - astarts[i])","
starts=starts""(astarts[i] = astarts[i] - $2)","
exonCount=exonCount + 1
}
print $1,$2,$3,$4,1,$5,$2,$3,"0",exonCount,sizes,starts
}' $ORG.notbed | sort -k1,1 -k2,2n > refGene.$ORG.bed
which you can save as refGene.sh and use as
sh refGene.sh hg19
or
sh refGene.sh mm9
this is very helpful. Thanks
thank you so much !