bash - SQL Query Outputs to variable

后端 未结 3 1520
悲&欢浪女
悲&欢浪女 2021-02-05 17:48

Im new in bash scripting. I want to save sql-query outputs in variable, but

actually I must connect for every query to mysql with:

mysql -u $MYUSER -p$MY         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-05 18:50

    I did this

    variable=mysql -u root -ppassworrd database << EOF select MAX(variable) AS a from table where variable2 = 'SOMETEXT' AND day(datevalue) >= 22; EOF

    I hope it helps

提交回复
热议问题