Skip to main content

SQL: customer name and address

Short answer

Select customer_name, customer_street, customer_city from Customer; concatenate street and city with || ', ' to form address.

Consider database schema: Account (acc_no, branch_name, balance) Branch (branch_name, branch_city, assets) Customer (customer_name, customer_street, customer_city) Loan (loan_no, branch_name, amount) Depositor (customer_name, acc_no) Borrower (customer_name, loan_no) List name and address of customer. (address = street, city)

Name and address both come from the Customer table, where the address is made of street and city. No join is needed.

SELECT customer_name, customer_street, customer_city
FROM   Customer;

To show the address as a single column, concatenate the two attributes (|| in standard SQL/Oracle/SQLite; CONCAT() in MySQL):

SELECT customer_name,
       customer_street || ', ' || customer_city AS address
FROM   Customer;

Relational algebra: Π customer_name, customer_street, customer_city (Customer)

Sample output:

customer_nameaddress
SujanS1, Dharan
RamS2, Pokhara

✓ Answer checked by Claude Opus 5.5 (high effort)

All Database Management System chapter 3 questions →