我已经宣布一个表为“m”仍然是查询给我一个恐怖。这是查询:
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) ))
答案 0 :(得分:2)
由于您在m
子句中将表格别名为FROM
,我认为您必须在{{1}中将其称为m
子句:
WHERE
答案 1 :(得分:2)
&LT 1为卤素;你有一个无与伦比的报价:
m.stream_off` AS stream_off
&LT 2 - ; USAGE
是保留字。你需要引用它:
m.usage AS `usage`
&LT 3的密度;如果要将1
用作列别名,则需要引用它:
select 1 AS '1'
......或:
select 1 AS `1`
...虽然当然没有必要使用自己的名称对列进行别名。
我建议您在几行中编写SQL代码,并使用带语法高亮的编辑器。这样可以更容易地发现这种错误。
答案 2 :(得分:0)
在WHERE子句中关闭了parens。你已经将m.status=1
埋在了存在的内部。我想你想在存在之外进行检查。
...
where m.status = 1
and exists(select 1 from vw_extr_active_socnet_product p where p.id = m.product_id)