sql - How to join multiple tables in Oracle -
i keep getting follow error "column ambiguously defined" input below. using oracle sql developer.
i in school , 1 of assignments. being said, unexperienced , need "child-like" explanation. assignment states, "create view list movies available renting. view should include title, category description (not category_code), company, director, actor, store, copy, type." think might joining many tables?!? or, obviously, not doing correctly. assistance tremendously appreciated.
create view availablemovies select m.title, mcat.description, comp.company_name, d.director_name, act.actor_name, mrs.store_name, mrl.available_for_rent, mrl.type_distributed companies comp join directors d on comp.company_id = d.company_id join movie_directors mdir on d.director_id = mdir.director_id join actor_in_movies aim on mdir.movie_id = aim.movie_id join actors act on aim.actor_id = act.actor_id join actor_in_movies aim on act.actor_id = aim.actor_id join order_items oi on aim.movie_id = oi.movie_id join orders o on oi.order_id = o.order_id join movie_rental_stores mrs on o.store_id = mrs.store_id join movie_rent_list mrl on mrs.store_id = mrl.store_id join movies m on mrl.movie_id = m.movie_id join movie_categories mcat on m.category_code = mcat.category_code order m.title;
if helps, below of tables assignment:
create table companies( company_id number(3), company_name varchar2(30) not null, description varchar2(100) ); create table movie_categories( category_code char(3) not null, description varchar2(50) ); create table movies ( movie_id number(5), title varchar2(30) not null, category_code char(3) not null, description varchar2(500), released_by number(3) not null, released_on date not null ); create table directors( director_id number(5), director_name varchar2(30) not null, company_id number(3) not null ); create table movie_directors( movie_director_id number(5), movie_id number(5) not null, director_id number(5) not null ); create table awards( award_id number(4), award varchar2(30) not null, award_description varchar2(100) ); create table movie_awards( movie_award_id number(5), movie_id number(5) not null, award_id number(4) not null, award_date date ); create table actors( actor_id number(5), actor_name varchar2(30) not null, gender char(1), contact varchar2(20) ); create table actor_in_movies( movie_actor_id number(5), movie_id number(5) not null, actor_id number(5) not null ); create table movie_distributors( distributor_id number(3), distributor_name varchar2(30) not null, location varchar2(40), contact varchar2(40) ); create table distributed_movie_list( distribution_id number(8), movie_id number(5) not null, distributor_id number(3) not null, distribute_type varchar2(10), inventory_quantity number(3) default 0, unit_price number(8,2) ); create table movie_rental_stores( store_id number(4), store_name varchar2(30) not null, store_location varchar2(50) ); create table orders( order_id number(8), store_id number(4) not null, description varchar2(30), total_items number(3), total_payment number(8,2), tax number(6,2), order_status varchar2(2), ordering_date date, order_completed_date date ); create table order_items( item_id number(10), order_id number(8) not null, distribution_id number(8) not null, movie_id number(5) not null, number_of_items number(3), item_unit_price number(5,2), item_sub_total number(10,2) ); create table movie_rent_list( title_id number(5), movie_id number(5) not null, store_id number(4) not null, number_in_store number(2), available_for_rent char(1), rent_unit_price number(5,2), type_distributed varchar2(10), overdue_unit_fee number(5,2) ); create table movie_copies( copy_id number(5), title_id number(5) not null, available char(1) default 'y' ); create table customers( customer_id number(5), store_id number(4) not null, firstname varchar2(20), lastname varchar2(20), gender char(1), address varchar2(50), card_approved char(1), card_approved_date date, phone_number varchar2(10), card_number number(10), rent_limit number(2), overdue_notified char(1) ); create table movie_rent_records( rent_record_id number(8), customer_id number(5) not null, copy_id number(5) not null, rented_date date, returned_date date, rent_fee number(5,2), overdue_fee number(5,2), overdue_days number(2) );
you need fix view.
the alias aim
being used twice. presumably causing problem.
Comments
Post a Comment