gpt4 book ai didi

Mysql 查询在服务器端执行时有效,但在客户端执行时无效

转载 作者:行者123 更新时间:2023-11-29 12:35:46 26 4
gpt4 key购买 nike

****解决方案***

我必须将查询用双引号而不是单引号括起来。

如果我登录到以下 mysql 服务器:

mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A

然后运行以下查询:

select distinct 
kgID, genesymbol, refseq
from
kgXref
where
genesymbol = 'GLRA1') a
inner join
(select * from knownGene) b on a.kgID = b.name
inner join
(select distinct
name, transcript, chromStart, chromEnd,
substr(peptides, 1, 1) as ref_pep,
substr(peptides, 3, 1) as mut_pep
from
snp137CodingDbSnp) c on a.refseq = c.transcript

我得到了我想要的结果。

但是,如果我按以下方式运行它:

mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A hg19 -D hg19 -e 'select distinct c.name,c.transcript from  (select distinct kgID,genesymbol,refseq from kgXref where genesymbol = 'GLRA1') a inner join (select * from knownGene) b on a.kgID = b.name inner join (SELECT distinct name, transcript,chromStart,chromEnd, substr(peptides,1,1) as ref_pep,substr(peptides,3,1) as mut_pep FROM snp137CodingDbSnp) c on a.refseq = c.transcript'

我收到以下错误

ERROR 1054 (42S22) at line 1: Unknown column 'GLRA1' in 'where clause'

其中 GLRA1 不是一列,而是列geneSymbol 中的一个id。

为什么当我登录到服务器时查询可以工作,但当我以第二种方式运行它时却不行?

最佳答案

简单 - 您过早结束“报价”:

-e 'select distinct c.name,c.transcript from  (select distinct kgID,genesymbol,refseq from kgXref where genesymbol = 'GLRA1')

GLRA1 之前的 ' 将关闭 select 关键字之前的开引号。

关于Mysql 查询在服务器端执行时有效,但在客户端执行时无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26819511/

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