简体   繁体   English

mysql:如何将存储过程的结果用作另一个存储过程中的表/视图

[英]mysql: how to use the result of a stored procedure as a table/view in another stored procedure

i have a table - Adjustments - that looks like 我有一张桌子-调整-看起来像

id | id | employee_id | employee_id | amount | 金额| earning/deduction 收入/扣除

I need to query this table to get the total earnings and another query to get the total deductions. 我需要查询该表以获取总收入,并查询另一个表以获取总扣除额。 the two queries will need a parameter - id. 这两个查询将需要一个参数-id。

i then need to create a 3rd query that will use the resulting table of those 2 queries. 然后,我需要创建第三个查询,该查询将使用这两个查询的结果表。 this 3rd query will also need the same parameter - id. 此第三个查询也将需要相同的参数-id。

is it possible to call the 3rd query, passing the parameter - id, which will also be used by the 1st and 2nd queries. 是否可以通过传递参数-id来调用第三查询,第一和第二查询也将使用该参数。

Thank you. 谢谢。

The first two can be done in one query. 前两个可以在一个查询中完成。 I'm betting it's possible all three can be don in one. 我敢打赌,这三个人可能合而为一。 But the answer is yes . 但是答案是肯定的

If you need more info, you have to give more info. 如果您需要更多信息,则必须提供更多信息。 Like all 3 queries. 像所有3个查询一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM