0

I have a problem with writing in the variable from table in MySQL database.

DB="--user=$OSD_USERNAME \
    --password=$OSD_PASSWORD \ 
    --database=$OSD_DB -N";
mysql --user="$user" \
      --password="$password" \
      --database="$database" \
      --execute="DROP DATABASE $user; CREATE DATABASE $database;"

id_customer = $(echo "SELECT id FROM customers WHERE customers.customer='John'"| mysql $DB)

My problem is that id_customer is still empty. When I connect to mysql databases and put there this:

SELECT id FROM customers WHERE customers.customer='John'

then it give me table like this

+----+
| id |
+----+
|  1 | 
+----+
1
  • It won't put on formatting if you call it with a piped in script. Try it out. Commented May 21, 2014 at 23:44

1 Answer 1

2

Only empty, no errors? Try remove spaces between variable name and $

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.