The first table is the user information to the customer (customer_name, customer_street customer_city)
The second form is branch information branch (branch_name, branch_city)
The third form is the account account information (account_name, branch_name, balance)
The fourth form is depositor deposit information (account_name, customer_name)
Use the SQL query in Beijing all branches open transfer user information? (branch_city=Beijing)
Using SQL queries in chaoyang branch only open one account user information? (branch_name=chaoyang)
1.
Select * from the customer where customer_name in
(
Select a.c ustomer_name from the customer a, b branch, account where c
A.c ustomer_city=b.b ranch_city
And b.b ranch_name=mount ranch_name
And b.b ranch_city='Beijing'
Group by a.c ustomer_name having the count (*)=
(select count (*) from branch where branch_city='Beijing')
);
2.
Select * from the customer where customer_name in
(select a.c ustomer_name from the customer a, branch b, c where the account
A.c ustomer_city=b.b ranch_city...
This is find the answer on the Internet, but is not correct, you really can't think again (nearly 3 hours)
Just want to here: select a_name from depositor D, the account A, B branch where B.b _city='wuhan' AND B.b _name=a. _name AND da _name=A.a _name; (a_name account_name, and so on)
CodePudding user response:
1.Select * from the customer where customer_name in
(select customer_name from
(select a.c ustomer_name, b.b ranch_name from the customer. A, b branch, account where c
A.c ustomer_city=b.b ranch_city and b.b ranch_name=mount ranch_name and b.b ranch_city='Beijing')
Group by customer_name having the count (*)=(select count (*) from branch where branch_city='Beijing')
);
2.
Select * from the customer where customer_name in
(select customer_name from
(select a.c ustomer_name, c.a. ccount_name from the customer. A, b branch, account where c
A.c ustomer_city=b.b ranch_city and b.b ranch_name=mount ranch_name and b.b ranch_name='chaoyang')
Group by customer_name having the count (*)=1
);
CodePudding user response:
2.Select * from the customer where customer_name in
(select customer_name from
(select a.c ustomer_name, c.a. ccount_name from the customer. A, b branch, account where c
A.c ustomer_city=b.b ranch_city and b.b ranch_name=mount ranch_name and b.b ranch_name='chaoyang')
Group by customer_name having the count (*)=1)
);
CodePudding user response:
- use SQL queries in Beijing all branches open transfer user information? (branch_city=Beijing)
The select Arthur c. ustomer_name, Arthur c. ustomer_street, Arthur c. ustomer_city
The from depositor d, customer c, branch b, the account a
Where b.b ranch_name=mount ranch_name and b.b ranch_city='Beijing' da ccount_name=and c.a. ccount_name and a.c ustomer_name=, dc ustomer_name;
- use the SQL query in chaoyang branch only open one account user information? (branch_name=chaoyang)
The select Max (Arthur c. ustomer_name), Max (Arthur c. ustomer_street), Max (Arthur c. ustomer_city), a.a ccount_name
The from depositor d, customer c, branch b, the account a
Where b.b ranch_name=mount ranch_name and b.b ranch_city='Beijing' da ccount_name=and c.a. ccount_name and a.c ustomer_name=, dc ustomer_name
Group by a.a ccount_name
Having a count (a.a ccount_name)=1
CodePudding user response: