22.9k views
1 vote
write another query to display the customer names, ids and addresses in the following format: allan sherwood, customerid: 1, address: 100 east ridgewood ave., paramus, nj 07652 it is ok to display multiple addresses for one customer.

1 Answer

3 votes

Below is the SQL query that retrieves the customer names, IDs, and addresses in the specified format:

The SQL Query

SELECT CON CAT(customer_name, ', customerid: ', customer_id, ', address: ', address) AS customer_info

FROM customers;

This SQL code uses the CON CAT function to combine the customer name, ID, and address into a single string in the requested format. The customer's table contains the necessary columns: customer_name, customer_id, and address.

This query will display the concatenated customer information as per the provided format for all customers, including multiple addresses if applicable.

The Complete Question

Write a SQL query to display the customer names, IDs, and addresses in the format "customer_name, customer_id: id_number, address: full_address." It is acceptable to display multiple addresses for a single customer.

User Pooks
by
8.6k points