Mysql 我得到了一个错误,即;未知表格“;错误?

Mysql 我得到了一个错误,即;未知表格“;错误?,mysql,Mysql,我已将a表声明为“m”,但查询仍会给我一个arror。以下是查询: select m.id AS id, m.product_id AS product_id, m.status AS `status`, m.pmatch AS pmatch, m.p_offset AS p_offset, m.smatch AS smatch, m.s_offset AS s_offset, m.tmatch A

我已将a表声明为“m”,但查询仍会给我一个arror。以下是查询:

select m.id AS id,
       m.product_id AS product_id,
       m.status AS `status`,
       m.pmatch AS pmatch,
       m.p_offset AS p_offset,
       m.smatch AS smatch,
       m.s_offset AS s_offset,
       m.tmatch AS tmatch,
       m.t_offset AS t_offset,
       m.txt1hex AS txt1hex,
       m.txt2hex AS txt2hex,
       m.txt3hex AS txt3hex,
       m.http_host AS http_host,
       m.http_uri AS http_uri,
       m.http_user_agent AS http_user_agent,
       m.http_cookie AS http_cookie,
       m.direction AS direction,
       m.trans AS trans,
       m.conn AS conn,
       m.min_pl_len AS min_pl_len,
       m.max_pl_len AS max_pl_len,
       m.stream_off AS stream_off,
       m.packet_num AS packet_num,
       m.sip AS sip,
       m.sp AS sp,
       m.dip AS dip,
       m.dp AS dp,
       m.stage AS stage,
       m.func_index AS func_index,
       m.usage AS usage,
       m.comments AS comments,
       m.created AS created,
       m.createdby AS createdby,
       m.updated AS updated,
       m.updatedby AS updatedby
from   sp_mip_rule m
where  exists(select 1 AS 1
              from vw_extr_active_socnet_product p
              where ((p.id = sp_mip_rule.product_id) and (sp_mip_rule.status = 1) ))

由于您在
FROM
子句中将该表别名为
m
,我认为您还必须在
WHERE
子句中将其称为
m

select m.id AS id,abunchofotherstuff
from sp_mip_rule m
where exists(select 1 AS 1 from vw_extr_active_socnet_product p where ((p.id = m.product_id) and (m.status = 1) ))

由于您在
FROM
子句中将该表别名为
m
,我认为您还必须在
WHERE
子句中将其称为
m

select m.id AS id,abunchofotherstuff
from sp_mip_rule m
where exists(select 1 AS 1 from vw_extr_active_socnet_product p where ((p.id = m.product_id) and (m.status = 1) ))

在你的WHERE子句中,paren一家不在了。您将
m.status=1
隐藏在exists中。我想你希望那张支票在银行之外

...
where m.status = 1 
    and exists(select 1 from vw_extr_active_socnet_product p where p.id = m.product_id)

在你的WHERE子句中,paren一家不在了。您将
m.status=1
隐藏在exists中。我想你希望那张支票在银行之外

...
where m.status = 1 
    and exists(select 1 from vw_extr_active_socnet_product p where p.id = m.product_id)
您有一个不匹配的报价:

m.stream_off` AS stream_off
用法
是保留字。你需要引用它:

m.usage AS `usage`
select 1 AS '1'
如果要使用
1
作为列别名,则需要引用它:

m.usage AS `usage`
select 1 AS '1'
。。。或:

select 1 AS `1`
。。。当然,没有必要用自己的名称为列别名

我建议您将SQL代码分成几行,并使用带有语法高亮显示的编辑器。这样可以更容易地发现此类错误。

您有一个不匹配的报价:

m.stream_off` AS stream_off
用法
是保留字。你需要引用它:

m.usage AS `usage`
select 1 AS '1'
如果要使用
1
作为列别名,则需要引用它:

m.usage AS `usage`
select 1 AS '1'
。。。或:

select 1 AS `1`
。。。当然,没有必要用自己的名称为列别名


我建议您将SQL代码分成几行,并使用带有语法高亮显示的编辑器。这使得发现此类错误变得更容易。

在这行
m.stream\u off`作为stream\u off,
反勾号是应该存在的吗?不,不是,我更正了它。它仍然不起作用为什么你要费心给这个表加别名?另外,如果你在很多行上写下你的陈述,MySQL消息可能会给你一个关于问题所在的更好的提示。在这一行
m.stream\u off`AS stream\u off,
反勾号应该在那里吗?不,不是,我更正了它。它仍然不起作用为什么你要费心给这个表加别名?另外,如果你把你的语句写在许多行上,MySQL消息可能会给你一个关于问题所在的更好的提示。它在where子句where((p.id=m.product_id)和(m.status=1)@vincy你的意思是这就是问题所在吗?看着你的代码我仍然看到
(p.id=sp_mip_rule.product_id)和(sp_mip_rule.status=1)
WHERE
中,WHERE子句WHERE((p.id=m.product\u id)和(m.status=1)中引用了m@vincy您的意思是这就是问题所在?查看您的代码,我仍然看到
(p.id=sp\u mip\u rule.product\u id)和(sp\u mip\u rule.status=1)
中,其中
@vincy:如果提供的答案中有一个解决了你的问题,请接受它。如果没有,请将你的答案作为答案发布,这样问题就可以结束了。@vincy:如果提供的答案中有一个解决了你的问题,请接受它。如果没有,请将你的答案作为答案发布,这样问题就可以结束了。