?
Solved

Store MySQL result in a variable

Posted on 2013-06-03
1
Medium Priority
?
536 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

777 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