CREATE VIEW tcs.meter_data_eb2 AS
select ar.created_date AS created_date,
p.id AS parameter_id,
p.parameter_name AS parameter_name,
ar.parameter_value AS parameter_value,
m.meter_primary_id AS meter_id,
m.meter_name AS meter_name
m.meter_code As meter_code
from tcs.parameter_values_archieve ar
inner join tcs.parameter_master p on p.id = ar.parameter_id
inner join tcs.meter_primary_master m on m.meter_primary_id = ar.meter_id
inner join tcs.meter_master mm on mm.meter_primary_id = m.meter_primary_id;
此查询有什么问题?
给出错误:
您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 靠近'm.meter_code作为来自tcs.parameter_values_archieve ar的meter_code 内联接tc'在第8行
答案 0 :(得分:3)
您只是在m.meter_name
和m.meter_code
, m.meter_name AS meter_name, m.meter_code AS meter_code
全视图查询,
CREATE VIEW tcs.meter_data_eb2
AS
SELECT ar.created_date AS created_date ,
p.id AS parameter_id ,
p.parameter_name AS parameter_name ,
ar.parameter_value AS parameter_value ,
m.meter_primary_id AS meter_id ,
m.meter_name AS meter_name,
m.meter_code AS meter_code
FROM tcs.parameter_values_archieve ar
INNER JOIN tcs.parameter_master p
ON p.id = ar.parameter_id
INNER JOIN tcs.meter_primary_master m
ON m.meter_primary_id = ar.meter_id
INNER JOIN tcs.meter_master mm
ON mm.meter_primary_id = m.meter_primary_id;