Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在MySQL select in bash脚本中使用单引号?_Mysql_Bash_Sh - Fatal编程技术网

如何在MySQL select in bash脚本中使用单引号?

如何在MySQL select in bash脚本中使用单引号?,mysql,bash,sh,Mysql,Bash,Sh,我有一个问题 Select id, contact_name from Profile where TRIM(IFNULL(contact_name,'')) <> '' 及 TRIM(如果为空('contact\u name`,\”) 及 TRIM(如果为空(`contact_name`,'')“” 我没有主意了 但它不喜欢单引号 我的机器上的Bash可以使用单引号: $ echo "SELECT id,contact_name from Profile where TRI

我有一个问题

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

TRIM(如果为空('contact\u name`,\”)

TRIM(如果为空(`contact_name`,'')“”
我没有主意了

但它不喜欢单引号

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

 $ echo "SELECT id,contact_name from Profile where TRIM(IFNULL(contact_name,'') <> ''"
 SELECT id,contact_name from Profile where TRIM(IFNULL(contact_name,'') <> ''
 $
$echo“从修剪位置的配置文件中选择id、联系人姓名(如果为空(联系人姓名)”)“””
从纵断面中选择id、联系人姓名(如果为空(联系人姓名“”)“”
$

如果要将整件事用双引号括起来,就不需要转义单引号。我不认为问题出在单引号上,但反勾号被解释为命令替换。由于格式原因,这个问题的反勾号很难看到,我想是它们造成了问题。我找到了自己的答案。mysql-u abc-pSomePass MyData-s-e“从contact_name“”所在的配置文件中选择id,contact_name”|同时读取-a Result;然后我是否循环通过结果数组id=Result[0]name=Result[1]等。。
TRIM(IFNULL(`contact_name`,\'\') <> \'\'"
TRIM(IFNULL(`contact_name`,\") <> \""
TRIM(IFNULL(`contact_name`,"''") <> "''""
 $ echo "SELECT id,contact_name from Profile where TRIM(IFNULL(contact_name,'') <> ''"
 SELECT id,contact_name from Profile where TRIM(IFNULL(contact_name,'') <> ''
 $