gpt4 book ai didi

mysql - 使用连接创建 View

转载 作者:太空宇宙 更新时间:2023-11-03 12:33:07 25 4
gpt4 key购买 nike

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;

这个查询有什么问题?

它给出的错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'm.meter_code As meter_code from tcs.parameter_values_archieve ar inner join tc' at line 8

最佳答案

您只是在 m.meter_namem.meter_code 之间缺少逗号>

, m.meter_name AS meter_name, m.meter_code AS meter_code

全 View 查询,

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;

关于mysql - 使用连接创建 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14453190/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com