MySQL error 'Key Column doesnt exist in table' -
heres input command line can see tried add foreign key in different ways , keep getting same error doing wrong?
mysql> create table membership( -> m_no char(3) primary key, -> m_fname varchar(15) not null, -> m_lname varchar(15) not null, -> m_street varchar(30) not null, -> m_city varchar(20) not null, -> m_st char(2) not null, -> m_balance varchar(3));
query ok, 0 rows affected (1.06 sec)
mysql> create table rental( -> r_no char(4) primary key, -> r_date date not null, -> foreign key (m_no) references membership(m_no)); error 1072 (42000): key column 'm_no' doesn't exist in table mysql> create table rental( -> r_no char(4) primary key, -> r_date date not null, -> foreign key (m_no) references membership); error 1072 (42000): key column 'm_no' doesn't exist in table mysql> create table rental( -> r_no char(4) primary key, -> r_date date not null, -> foreign key (m_no) references membership) -> engine=innodb; error 1072 (42000): key column 'm_no' doesn't exist in table mysql> create table rental( -> r_no char(4) primary key, -> r_date date not null, -> foreign key (m_no) references membership(m_no)) -> engine=innodb; error 1072 (42000): key column 'm_no' doesn't exist in table mysql> create table rental( -> r_no char(4) primary key, -> r_date date not null);
query ok, 0 rows affected (0.22 sec)
mysql> alter table rental add foreign key (m_no) references membership(m_no); error 1072 (42000): key column 'm_no' doesn't exist in table
mysql>
the error statement clear. not have column named 'm_no' in rental table.
is after:
create table rental ( r_no char(4) primary key, r_date date not null, foreign key (r_no) references membership(m_no) );
Comments
Post a Comment