gpt4 book ai didi

mysql - 如何在 bash 脚本中的 MySQL select 中使用单引号?

转载 作者:行者123 更新时间:2023-11-29 15:37:57 25 4
gpt4 key购买 nike

我有一个疑问

Select id, contact_name from Profile where TRIM(IFNULL(contact_name,'')) <> ''

我正在尝试将其传递到 Bash 脚本中。

mysql --user abc -psomePass MyData -e "SELECT `id`,`contact_name` from `Profile` where TRIM(IFNULL(`contact_name`,'') <> ''" | while read term_id; do
done

但它不喜欢单引号 '' 。如何在脚本中格式化它?

我已经尝试过

TRIM(IFNULL(`contact_name`,\'\') <> \'\'"

TRIM(IFNULL(`contact_name`,\") <> \""

TRIM(IFNULL(`contact_name`,"''") <> "''""

我没有主意了。

最佳答案

but it doesn't like the single quotes.

我的机器上的 Bash 可以使用单引号:

 $ echo "SELECT id,contact_name from Profile where TRIM(IFNULL(contact_name,'') <> ''"
SELECT id,contact_name from Profile where TRIM(IFNULL(contact_name,'') <> ''
$

关于mysql - 如何在 bash 脚本中的 MySQL select 中使用单引号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58034287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com