how to redirect a error returned from mysql syntax

Following is a shell file in linux. I am executing a mysql query from the file. I want the error from the execution to be redirected to a file.
The present redirection does not redirect the mysql errors.

# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 95 10

mysql -u${MYSQL_ROOT_USER} -p${MYSQL_ROOT_PASSWORD} -e "show tables in omcr;" 1>/dev/null 2>&1
   if [ $isTables -ne 0 ] ; then
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

it is redirecting to /dev/null which is pasically to ignore or trash the output and errors. You may do it like

mysql -u${MYSQL_ROOT_USER} -p${MYSQL_ROOT_PASSWORD} -e "show tables in omcr;" 1>/dev/null 2> /path/to/mysql_errors
pvinodpAuthor Commented:
it does not work.. i still get error prompted on to my screen
Ok, if you want to see the program output, but not the errors, you want to change that to

omcr;" &2>~/errors.txt

If you don't want program output, but you do want error redirection
omcr;" &1> /dev/null &2>~errors.txt

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
possibly the problem is with mysql try inside mysql:

mysql> pager '/dev/null'
pvinodpAuthor Commented:
I have managed to rewrite the sql query which will not generate a error. thanks anyways
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.