更新查询在脚本中不起作用

时间:2017-08-21 11:07:26

标签: bash sqlite sh

我想更新'非活动'对于其状态为活动状态的选定客户价值,我尝试这样做,但它不会更新“非活动”状态。对于选定的客户。任何人都知道什么是错的,请告诉我。感谢名单!

#!/bin/bash

echo " --- Enter the Database name ---" #name of the database
read databasename

echo " --- enter the table name --- " #name of the table
read table_name

sqlite3 $databasename.db $table_name;

sqlite3 $databasename.db "select * from $table_name WHERE cus_status = 'Active';"

echo "---Select the domain to make Inactive---"
read inactive_user


sqlite3 $databasename.db  "UPDATE $table_name SET cus_status = 'Inactive' WHERE cus_name = $inactive_user $table_name";


sqlite3 $databasename.db "select * from $table_name";

1 个答案:

答案 0 :(得分:1)

检查列cus_name的数据类型。我假设它是varchar。 因此,您可以尝试$inactive_user

而不是'$inactive_user'

"UPDATE $table_name SET cus_status = 'Inactive' WHERE cus_name = '$inactive_user' $table_name;"