syntax issue mysql in bash script

I'm running mysql in a bash script

mysql <<EOF
query
EOF

one query is like this:

UPDATE $dbname.$prefix"config" SET  value = $var WHERE  "$prefix"config.name =  'table colname';

with variable
but it's giving an error
i'm not sure what to put for

"$prefix"config.name 

the table name is like
prefix_config
where that is one word
and name is a field name in that table

i'm not sure about the syntax, does anyone know the problem? thanks!

There's no _ in

$prefix"config"

?

Also, try

set -x 

under
#!/bin/bash

in your script and then run the script manually, you'll see tons of diagnostic "goodies" :slight_smile:

well the prefix contains the _
the prefix is a string like cg_

Why the extra quoting?
Your input to mysql would be for example

UPDATE db.prefix_"config" SET  value =  WHERE  "prefix_"config.name =  'table colname';

I suppose the problem is getting $prefix to expand correctly, because it will try to expand $prefix_config. try using ${prefix}

UPDATE $dbname.${prefix}config SET  value = '$var' WHERE  ${prefix}config.name =  'table colname';
1 Like