1

I have a file that is filled with statements that appear like the following:

update table set column1=NULL where column2 in (select id from users where user_id in ('user1','user2'));

As you can see this is correct syntax. When I run this command manually on the mysql command line it works as intended.

However when I attempt to source the file I get syntax errors. Has anyone seen this issue before? I'm looking for a resolution...

mysql> \! source /tmp/update_users.sql
/tmp/update_users.sql: line 2: syntax error near unexpected token `('
/tmp/update_users.sql: line 2: `(select id from users where user_id in ('user1','user2'));'

1 Answer 1

3

You have to use the MySQL source command:

mysql> source /tmp/update_users.sql

When you use \!, you instead invoke a shell command. The shell source command expects a shell script, not a sql file.

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

1 Comment

Aye! I had a brain fart LOL -- thanks for the quick response!

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.