mysql创建视图,A表中搜索id,b,c,d,通过A.id=B.id搜索B表最新年份的a,b,c,d的总和该怎么写代码啊?

mysql创建视图,A表中搜索id,b,c,d,通过A.id=B.id搜索B表最新年份的a,b,c,d的总和该怎么写代码啊?,第1张

create view Myvw

as

select Sum(A.a)+sum(A.b)+sum(A.c)+sum(A.d) from A ,B on A.id=B.id where year(B.日期)=year(getdate())

select * from a

inner join (select id from v_c group by id having count(1)<2) c on a.id=c.id

where not exists (select * from v_b where a.id =v_b.id)

视图

SQL Server

select

a.name AS ViewName,

c.text AS CreateViewSQL

from

sys.views a

LEFT OUTER JOIN

dbo.syscomments c ON a.object_id = c.id

order by

a.name

MySQL

是否是视图 通过 table_type 字段是否为 VIEW 来区分的。

SELECT

table_name AS `视图名`,

table_type AS `类型`,

engine AS `引擎`,

table_comment AS `备注`

FROM

information_schema.tables

WHERE

table_schema = 'test' AND table_type = 'VIEW'

ORDER BY

table_name DESC

存储过程

SQL Server

select

pro.name AS ProcedureName,

c.text AS CreateProcedureSQL

from

sys.procedures pro LEFT OUTER JOIN

dbo.syscomments c ON pro.object_id = c.id

MySQL 里面,查存储过程的,我这里暂时没有


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/8634626.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-19
下一篇 2023-04-19

发表评论

登录后才能评论

评论列表(0条)

保存