如何从多个表中查询?

时间:2020-12-27 00:51:07

You are given a bank database witht the following schema :

您将获得一个具有以下架构的银行数据库:

Customer (Cust_id, Cust_name, Cust_dob, Cust_street, Cust_city);

客户(Cust_id,Cust_name,Cust_dob,Cust_street,Cust_city);

Account (Account_id, Balance, Type);

帐户(Account_id,余额,类型);

Branch(Branch_name, Branch_city, Assets);

分支(Branch_name,Branch_city,Assets);

Employee(Employee_id,Employee_name,Employee_dob,Employee_street,Employee_startdate);

Loan(Loan_id, Amount);

Borrower(Cust_id,Loan_id);

Depositor(Cust_id,Account_id);

Cust_banker(Customer_id,Employee_id);

Loan_Branch(Loan_id,Branch_name);

Write SQL commands to answer the following queries:

编写SQL命令以回答以下查询:

  • a) Find only the branches located in 'Horseneck'

    a)只找到位于'Horseneck'的分支

  • b) Find names and date of birth for all customers with loan greater than 1400.

    b)查找贷款金额超过1400的所有客户的姓名和出生日期。

  • c) Find the names of all bracnhes that have accets less than that of all branches located in *lyn.

    c)找出所有比布鲁克林所有分支机构的名称少的名字。

  • d) Create a view that displays the Branch Name and their maximum Loan Amount in ascending order of the maximum loan amount of that branch.

    d)创建一个视图,以该分支的最大贷款金额的升序显示分支名称及其最大贷款金额。

  • e) Insert a loan account 'L-26' with amount 10000 for customer 'C000000010'.

    e)为客户'C000000010'插入金额为10000的贷款账户'L-26'。

1 个解决方案

#1


0  

You can a lot of "functions".

你可以有很多“功能”。

To select who borrowed something, you can use

要选择借来的东西,你可以使用

"SELECT loan_id FROM customer JOIN borrower ON customer.cust_id=borrower.cust_id AND cust_name='hocpana';

because tabels customer and borrower had a similar word, cust_id.

因为表格客户和借款人有类似的词,cust_id。

Hope my words help! :)

希望我的话帮助你! :)

#1


0  

You can a lot of "functions".

你可以有很多“功能”。

To select who borrowed something, you can use

要选择借来的东西,你可以使用

"SELECT loan_id FROM customer JOIN borrower ON customer.cust_id=borrower.cust_id AND cust_name='hocpana';

because tabels customer and borrower had a similar word, cust_id.

因为表格客户和借款人有类似的词,cust_id。

Hope my words help! :)

希望我的话帮助你! :)