Reputation: 41
Create View ViewA AS
Select o.orderid, o.dishid, o.quantity, o.ordertime, o.deliveryaddress, d.dishid, r.description, r.location, c.firstname, c.lastname, c.phonenumber, c.address, c.city, c.state, c.zip
FROM Orders o
JOIN Dishes d On (o.dishid = d.dishid)
JOIN Customers c ON (o.customerid = c.customerid)
JOIN Restaurants r ON (d.restaurantid = r.restaurantid);
I am supposed to create a view like this but i do not understand the error that reads:
ORA-00957: duplicate column name 00957. 00000 - "duplicate column name"
Where is the duplicate column name?
Upvotes: 0
Views: 58
Reputation: 59997
You have o.dishid
and d.dishid
- oracle will try to call both dishId
- You need to alias them
Upvotes: 0
Reputation: 591
You must provide aliases for every column.
Run this:
Create View ViewA AS Select o.orderid ORDER_ID, o.dishid ORDER_DISH_ID, o.quantity ORDER_QUANTITY, o.ordertime ORDER_TIME, o.deliveryaddress DELIVERY_ADDRESS, d.dishid DISH_ID, r.description RES_DESCRIPTION, r.location RES_LOCATION, c.firstname CUST_FIRSTNAME, c.lastname CUST_LASTNAME, c.phonenumber CUST_PHONE, c.address CUST_ADDRESS, c.city CUST_CITY, c.state CUST_STATE, c.zip CUST_ZIP FROM Orders o JOIN Dishes d On (o.dishid = d.dishid) JOIN Customers c ON (o.customerid = c.customerid) JOIN Restaurants r ON (d.restaurantid = r.restaurantid);
Upvotes: 1