UNIX variable not working in sql resultset

Hi,
I am trying to extend unix variable value with mysql resultset. It's working fine in terminal but not working in shell script.

#!/bin/bash
export prcs_nm=$1
export tbl_nm=$2
export rslt=$(
mysql -sN -u root -proot123 -e "
select sql_query
from retail_db.config where prcs_nm = '$prcs_nm'
"
)
echo "$rslt"

Shell script resultset :

PRCS_1
products
mysql: [Warning] Using a password on the command line interface can be insecure.
'select \\* from $tbl_nm'

Working fine in terminal :

~/scripts$ tbl_nm=products
~/scripts$ t_rslt="'select \\* from $tbl_nm'"
~/scripts$ echo $t_rslt
'select \* from products'
~/scripts$ echo "$t_rslt"
'select \* from products'
 Could you please let me know why it's not working in shell script?

Thanks,
Prasad.

How do you call your script on the command line, what parameters do you pass to the script?

Thanks for the response.
I'm calling my scripts as

./test_ext.sh PRCS_1 products

PRCS_1 (1st Parameter)
products (2nd Parameter)

Moderator comments were removed during original forum migration.

1 Like