2

How can i parse a variable in a mysql update statement in a bash script?

i have this but its not going to work

mysql -h HOST -u USERNAME -pUGUESIT -D DATABASE -bse "DELETE FROM table WHERE Position='" . $4 ."'; DELETE FROM table WHERE Instance='" . $4 . "';" 

ofcourse username and pass etc are correct but not for public. The question is how I can use the $4 in the statement...

Thanks in advance!

1 Answer 1

5

You should be able to do it like this:

"DELETE FROM table WHERE Position='$4'; DELETE FROM table WHERE Instance='$4';" 
Sign up to request clarification or add additional context in comments.

2 Comments

ERROR 1142 (42000) at line 1: DELETE command denied to user 'USER'@'IP' for table 'table' im sure i got the rights becouse without $1 and with like 1 it will delete Instance 1
Thnx it works now. found the problem. need to do databasename.table in the query

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.