Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Store MySQL result in a variable

Posted on 2013-06-03
1
Medium Priority
?
545 Views
Last Modified: 2013-06-03
How would I store the MySQL code below into a variable?

    mysql --host=localhost --user=root --password=admin table <<EOF 2 >> logfile.log
    insert into video (title, description, url_video, upload_date) 
    values('testing','default_description','$filename', '$date_field');
    EOF

Open in new window


I want the script to log MySQL errors to the logfile and need to result of the query to be stored as a variable so it can be used a few times later in the script.
0
Comment
Question by:ipconfig610
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 39216302
VAR=$(
mysql --host=localhost --user=root --password=admin table <<EOF 2 >> logfile.log
insert into video (title, description, url_video, upload_date)
values('testing','default_description','$filename', '$date_field');
EOF
)

echo "$VAR"
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question