gpt4 book ai didi

mysql - 如何在 SQL 中显示 View 和查询的完整查询

转载 作者:行者123 更新时间:2023-11-29 21:09:15 25 4
gpt4 key购买 nike

我在家庭作业中遇到问题,我需要显示 DBMS 实际执行的完整查询。

View 是

create view MAJOR_CUSTOMER as
select customer_num, customer_name, balance, credit_limit, rep_num
from customer
where credit_limit < 10001;

我使用的查询是

select customer_name, customer_num
from major_customer
where balance > credit_limit;

我不明白如何做的一件大事是选择 View 中显示的所有内容,并在另一个查询中选择并仅显示 customer_name 和 customer_num。

最佳答案

选择 View 中的所有内容可以通过以下方式实现

SELECT *
FROM major_customer;

至于仅选择 customer_name 和 customer_num,您的查询应该有效,但要选择所有内容,只需删除 where 子句即可:

SELECT customer_name, customer_num
FROM major_customer;

关于mysql - 如何在 SQL 中显示 View 和查询的完整查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36536650/

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