Mysql Error 1072
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about error 1072 key column doesn't exist in table hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask
Police Code 1072
Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. error code 1072 mysql workbench Join them; it only takes a minute: Sign up MySQL error 'Key Column doesnt exist in table' up vote 1 down vote favorite heres my input into the command line you can see I tried to add a foreign
Error Code 1215 Mysql
key in different ways and keep getting the same error what am I 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 1215 (hy000): cannot add foreign key constraint 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> mysql share|improve this question edited Apr 5 '13 at 19:16 David Starkey 1,21711235 asked Apr 5 '13 at 19:10 Daniel 35128 add a comment| 3 Answers 3 active oldest votes up vote 2 down vote The error statement is clear. You do not have a column named 'm_no' in your rental table. Is this what you were after: Create table rental ( r_no char(4) primary key, r_date date not null, foreign key (r_no) references membership(m_no) ); share|improve this answer answered Apr 5 '13 at 19:13 Vaibhav
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site
Mysql Error 1215
About Us Learn more about Stack Overflow the company Business Learn more about
Mysql Foreign Key
hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySQL ERROR 1072: http://stackoverflow.com/questions/15841663/mysql-error-key-column-doesnt-exist-in-table States Key doesn't exist, yet it does exist up vote 0 down vote favorite Apologies if this is a newbie question, but I have been unable to resolve this problem for some time and am hoping someone with a better understand of MySQL can assist me in deciphering the following problem: I have two tables that I want to maintain so that users can define http://stackoverflow.com/questions/12557344/mysql-error-1072-states-key-doesnt-exist-yet-it-does-exist their preferences, while an admin can maintain their access rights to those preferences. And I want to make sure that if an admin removes certain rights, that the preferences table gets updated: The two tables are: main_access +--------------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+---------+------+-----+---------+-------+ | nav_location | int(11) | NO | PRI | NULL | | | user_id | int(11) | NO | PRI | NULL | | +--------------+---------+------+-----+---------+-------+ and main_prefs +--------------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+---------+------+-----+---------+-------+ | nav_location | int(11) | NO | PRI | NULL | | | user_id | int(11) | NO | PRI | NULL | | +--------------+---------+------+-----+---------+-------+ They both have unique indexes, as I run this: CREATE TABLE IF NOT EXISTS main_access ( nav_location integer not null, user_id integer not null, unique index uk_access (nav_location, user_id) ); CREATE TABLE IF NOT EXISTS main_pref ( nav_location integer not null, user_id integer not null, unique index uk_pref (nav_location, user_id) ); So, uk_access, and uk_pref with the above tables are being created. Yet, when I run: ALTER TABLE main_pref ADD CONSTRAINT FK_access1 FOREIGN KEY(uk_pref)
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of http://stackoverflow.com/questions/27076055/error-1072-key-column-course-id-does-not-exist this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up mysql error Error 1072: Key Column `course_id` does not exist up vote -1 down vote favorite I'm trying to make a simple table with foreign keys but it seems there's a problem with the id. I've tried everything but still comes up with an error message please help. Thanks. CREATE TABLE `staff_info`( `staff_id` INT NOT NULL AUTO_INCREMENT, `first_name` VARCHAR(45) NOT NULL, `last_name` VARCHAR(45) NOT NULL, `office_add` mysql error 1072 VARCHAR(45) NOT NULL, `email` INT NULL, `changed` TIMESTAMP, PRIMARY KEY (`staff_id`), FOREIGN KEY(`course_id`) REFERENCES `course_info`(`course_id`) ) ENGINE = InnoDB; CREATE TABLE `course_info`( `course_id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(45) NOT NULL, `module` VARCHAR(45) NOT NULL, `StartDate` TIMESTAMP, `EndDate` TIMESTAMP, `course_Update` TIMESTAMP, PRIMARY KEY(`course_id`), FOREIGN KEY(`student_id`) REFERENCES student(`student_id`) ) ENGINE = InnoDB; CREATE TABLE `student` ( `student_id` INT NOT NULL AUTO_INCREMENT, `first_name` VARCHAR(45) NOT NULL, `end_name` VARCHAR(45) NOT NULL, `gender` VARCHAR(45) NOT NULL, `email` VARCHAR(25) NULL, `phone` VARCHAR(20) NOT NULL, `student_update`TIMESTAMP, PRIMARY KEY(`student_id`) ); mysql share|improve this question edited Nov 22 '14 at 10:04 Anik Islam Abhi 18.8k72042 asked Nov 22 '14 at 9:50 Edrian 73 add a comment| 3 Answers 3 active oldest votes up vote 0 down vote accepted Your table destruct and creation orders are invalid CREATE TABLE `student` ( `student_id` INT NOT NULL AUTO_INCREMENT, `first_name` VARCHAR(45) NOT NULL, `end_name` VARCHAR(45) NOT NULL, `gender` VARCHAR(45) NOT NULL, `email` VARCHAR(25) NULL, `phone` VARCHAR(20) NOT NULL, `student_update`TIMESTAMP, PRIMARY KEY(`student_id`) ); CREATE TABLE `course_info`( `course_id` INT NOT NULL AUTO_INCREMENT, `student_id` INT, `name` VARCHAR(45) NOT NULL, `module` VARCHAR(45) NOT NULL, `StartDate` TIMESTAMP, `EndDate` TIMESTAMP, `course_Update` TIMESTAMP, PRIMARY KEY(`course_id`), FOREIGN KEY(`s