TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dorababu Meka
226
8.3k
1.7m
Error Code 1005 in mysql while applying Foreign key to a table
Oct 1 2011 1:06 AM
I am having two tables tbluserlogindetail and tblRoles.
tbluserlogindetail is as follows
CREATE
TABLE
`
tbluserlogindetail
`
(
`
ID
`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`
LoginID
`
varchar
(
45
)
NOT
NULL
,
`
Name
`
varchar
(
45
)
DEFAULT
NULL
,
`
Password
`
varchar
(
45
)
DEFAULT
NULL
,
PRIMARY
KEY
(`
ID
`,`
LoginID
`)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
latin1
$$
and my second table tblRoles is as follows
CREATE
TABLE
`
tblroles
`
(
`
RoleID
`
int
(
11
)
NOT
NULL
,
`
LoginID
`
varchar
(
45
)
NOT
NULL
,
PRIMARY
KEY
(`
RoleID
`,`
LoginID
`)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
latin1
$$
I tried the the following to assign a primary key for the column LoginID in tblroles table but i don't know where i went wrong can any one help me.
I have gone through the documentation but unable to rectify the error so please help me
ALTER TABLE tblroles ADD FOREIGN KEY (loginid) REFERENCES tbluserlogindetail(loginid)
Reply
Answers (
0
)
How to avoid use of Cursor
SOUNDEX function in SQL