0
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 服务器版本相对应的手册,以在第 8 行的“m.meter_code Asmeter_code from tcs.parameter_values_archieve ar inner join tc”附近使用正确的语法

4

1 回答 1

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;
于 2013-01-22T07:03:11.440 回答