Question

In: Computer Science

Create a view named customer_addresses that shows the shipping and billing addresses for each customer. This...

Create a view named customer_addresses that shows the shipping and billing addresses for each customer. This view should return these columns from the Customers table: customer_id, email_address, last_name and first_name. This view should return these columns from the Addresses table: bill_line1, bill_line2, bill_city, bill_state, bill_zip, ship_line1, ship_line2, ship_city, ship_state, and ship_zip.

I have this

CREATE VIEW customer_addresses AS

SELECT customer_id, email_address, last_name, first_name,
bill_line1, bill_line2, bill_city, bill_state, bill_zip,
ship_line1, ship_line2, ship_city, ship_state, ship_zip

FROM Customers, Addresses

WHERE Customers.customer_id = Addresses.customer_id

ORDER BY last_name, first_name;

Error Code: 1052. Column 'customer_id' in field list is ambiguous

Solutions

Expert Solution

Changes to be made:

i) Error Code: 1052 means SQL cannot read or support 'customer_id'. It means SQL don't know from where to choose customer_id column either from Customers table or Addresses table because it is available in both tables. (The word 'ambiguos' means 'uncertain')

To solve this problem,you need to prefix your customer_id with the table you want to choose it from.

ii) Use JOIN to retrieve fields from multiple tables.

The syntax for INNER JOIN is,

SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;

Now the usable query becomes,

CREATE VIEW customer_addresses AS

SELECT Customers.customer_id, Addresses.customer_id, email_address, last_name, first_name,bill_line1, bill_line2, bill_city, bill_state, bill_zip,
ship_line1, ship_line2, ship_city, ship_state, ship_zip

FROM Customers

INNER JOIN Addresses ON Addresses.customer_id = Customers.customer_id

ORDER BY last_name, first_name;


Related Solutions

In this project, you will create a Visual Basic solution to perform customer billing at the...
In this project, you will create a Visual Basic solution to perform customer billing at the Cyberian Internet Cafe. Please see below for the detailed instructions. You will create the project and then design a form using the image provided here. Then, add the necessary code to do the billing calculation and display the amount due. Instructions In this case, you will create a Visual Basic solution that performs customer billing for the Cyberian Internet Café. The Cyberian Internet Café...
Create a class named Billing that includes three overloaded computeBill() methods for a photo book store....
Create a class named Billing that includes three overloaded computeBill() methods for a photo book store. • When computeBill() receives a single parameter, it represents the price of one photo book ordered. Add 8% tax, and return the total due. • When computeBill() receives two parameters, they represent the price of a photo book and the quantity ordered. Multiply the two values, add 8% tax, and return the total due. • When computeBill() receives three parameters, they represent the price...
Create a class named Billing that includes three overloaded computeBill() methods for a photo book store....
Create a class named Billing that includes three overloaded computeBill() methods for a photo book store. • When computeBill() receives a single parameter, it represents the price of one photo book ordered. Add 8% tax, and return the total due. • When computeBill() receives two parameters, they represent the price of a photo book and the quantity ordered. Multiply the two values, add 8% tax, and return the total due. • When computeBill() receives three parameters, they represent the price...
Java Create a class named Billing that includes three overloaded computeBill() methods for a photo book...
Java Create a class named Billing that includes three overloaded computeBill() methods for a photo book store. main() main() will ask the user for input and then call functions to do calculations. The calculations will be returned to main() where they will be printed out. First function Create a function named computeBill that receives on parameter. It receives the price of an item. It will then add 8.25% sales tax to this and return the total due back to main()....
SUBJECT: PROGRAMMING IN SQL 1. Create a view named vDepartmentInstructors that returns these columns: the DepartmentName...
SUBJECT: PROGRAMMING IN SQL 1. Create a view named vDepartmentInstructors that returns these columns: the DepartmentName column from the Departments table the LastName, FirstName, Status, and AnnualSalary columns from the Instructors table. 2. Write a SELECT statement that returns all the columns from the vDepartmentInstructors view that you created in question 1. Return one row for each fulltime instructor in the English department. 3. Write an UPDATE statement that updates the vDepartmentInstructors view you created in question 1 so it...
Create a view named ReservationCustomer_VW. It consists of the reservation ID, trip ID, trip name, trip...
Create a view named ReservationCustomer_VW. It consists of the reservation ID, trip ID, trip name, trip date, customer number, customer last name, customer first name, and phone number for trips whose guide is Glory Unser or Susan Kiley. Show the SQL Server code for this view.
Find the subnet addresses, the broadcast addresses, and the range of available addresses for each given...
Find the subnet addresses, the broadcast addresses, and the range of available addresses for each given IPv4 address. 129.153.192.0/22 Network in Binary: __ __ __ __ __ __ __ __ . __ __ __ __ __ __ __ __ . __ __ __ __ __ __ __ __ . __ __ __ __ __ __ __ __          Dotted decimal: ______. ______ . _____ . _____ Broadcast: __ __ __ __ __ __ __ __. __ __ __ __ __ __...
Form for a user to enter billing and shipping information. Checkbox that when clicked copies all...
Form for a user to enter billing and shipping information. Checkbox that when clicked copies all of the billing information to the shipping information. A submit button to make sure the text fields have been filled. Just trying to make a simple small webpage to order a couple Items like toys for instance nothing fancy or big just small and simple, a couple of text fields. That's all JavaScript/HTML
The basic business activities performed in the revenue cycle are sales order entry, shipping, billing, cash...
The basic business activities performed in the revenue cycle are sales order entry, shipping, billing, cash collections. Please describe these activities.
Create a file named StudentArrayList.java,within the file create a class named StudentArrayList. This class is meant...
Create a file named StudentArrayList.java,within the file create a class named StudentArrayList. This class is meant to mimic the ArrayList data structure. It will hold an ordered list of items. This list should have a variable size, meaning an arbitrary number of items may be added to the list. Most importantly this class should implement the interface SimpleArrayList provided. Feel free to add as many other functions and methods as needed to your class to accomplish this task. In other...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT