Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/55.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.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 联合所有查询在VBA中失败,但在SQL中正常_Mysql_Vba - Fatal编程技术网

Mysql 联合所有查询在VBA中失败,但在SQL中正常

Mysql 联合所有查询在VBA中失败,但在SQL中正常,mysql,vba,Mysql,Vba,我试图运行下面的查询,但它显示了一个错误,在“unionselect”附近有不正确的语法,有人能帮忙吗 strsql = "select distinct a.LOCID,locnum,locname,streetname,city,county,statecode,state,peril,SITEDEDAMT,SITELIMAMT,COMBINEDDEDAMT,COMBINEDLIMAMT from eqdet a inner join loccvg b on a.LOCID=b.locid

我试图运行下面的查询,但它显示了一个错误,在“unionselect”附近有不正确的语法,有人能帮忙吗

strsql = "select distinct a.LOCID,locnum,locname,streetname,city,county,statecode,state,peril,SITEDEDAMT,SITELIMAMT,COMBINEDDEDAMT,COMBINEDLIMAMT from eqdet a inner join loccvg b on a.LOCID=b.locid inner join loc c on b.LOCID=c.LOCID where PERIL=1" & _
   "union" & _
  "select distinct a.LOCID,locnum,locname,streetname,city,county,statecode,state,peril,SITEDEDAMT,SITELIMAMT,COMBINEDDEDAMT,COMBINEDLIMAMT from hudet a  inner join loccvg b on a.LOCID=b.locid inner join loc c on b.LOCID=c.LOCID where peril=2" & _
  "union" & _
    "select distinct a.LOCID,locnum,locname,streetname,city,county,statecode,state,peril,SITEDEDAMT,SITELIMAMT,COMBINEDDEDAMT,COMBINEDLIMAMT from todet a  inner join loccvg b on a.LOCID=b.locid inner join loc c on b.LOCID=c.LOCID where peril=3" & _
    "union" & _
   "select a.LOCID,locnum,locname,streetname,city,county,statecode,state,peril,SITEDEDAMT,SITELIMAMT,COMBINEDDEDAMT,COMBINEDLIMAMT from fldet a  inner join loccvg b on a.LOCID=b.locid inner join loc c on b.LOCID=c.LOCID where peril=4" & _
   "union" & _
 "select distinct a.LOCID,locnum,locname,streetname,city,county,statecode,state,peril,SITEDEDAMT,SITELIMAMT,COMBINEDDEDAMT,COMBINEDLIMAMT from frdet a  inner join loccvg b on a.LOCID=b.locid inner join loc c on b.LOCID=c.LOCID where peril=5" & _
 "union" & _
 "select distinct a.LOCID,locnum,locname,streetname,city,county,statecode,state,peril,SITEDEDAMT,SITELIMAMT,COMBINEDDEDAMT,COMBINEDLIMAMT from trdet a  inner join loccvg b on a.LOCID=b.locid inner join loc c on b.LOCID=c.LOCID where peril=6"

查看错误消息,我怀疑您正在使用字符串进行查询
unionselect
应该是两个单词,用空格分隔。(
union-select
)我认为在您的代码空间中缺少单独的关键字

见:

将产生

…其中PERIL=1不选择不同的…

输出。正确的代码(注意联合体周围的空格):


查看错误消息,我怀疑您正在使用字符串进行查询
unionselect
应该是两个单词,用空格分隔。(
union-select
)我认为在您的代码空间中缺少单独的关键字

见:

将产生

…其中PERIL=1不选择不同的…

输出。正确的代码(注意联合体周围的空格):

"...where PERIL=1" & _ "union" & _ "select distinct..."
"...where PERIL=1" & _ " union " & _ "select distinct ..."