我正在尝试获取一个记录集,并从中读取一些字段。我无法弄清楚如何将字段放入变量。脚本是:

#!/bin/bash
sqlQuery="$(mysql -h host -u user -ppass -D oberonsaas_v2 -s -N -e
'select ventas.id_venta,
ventas_entradas.id_ventas_entradas,
ventas.id_evento,
id_tarifa,
DATE_FORMAT(fecha_evento,"%Y%m%d") as fecha,
TIME_FORMAT(pase,"%H%i") as pase

from pases,ventas,ventas_entradas,recintos

where ventas.id_recinto = recintos.id_recinto
and ventas.id_pase = pases.id_pase
and ventas.id_venta = ventas_entradas.id_venta
and recintos.id_cliente = 32
and ventas.estado="Pagada"
and date(fecha_venta) = date_add(date(CURRENT_TIMESTAMP),INTERVAL -1 day)')"
echo $sqlQuery


我在$ sqlQuery中获得了所有记录集,但是我想做一个循环并连接这些字段。

最佳答案

好吧,我发明了一些输出

输出是

#!/bin/bash

Result="21,336,purchase,tarif_exspensive,Jose"
(IFS=","
for i in $Result
do
    echo "I Have: " $i
done
)

10-06 13:57