Hello
I m not so expert in web design. I need ur help.
I have two table. One has a primary key and other foreign key. I want that foreign key must be from primary key. other than primary key it will not except any value. I made relationship from phpmyadmin. but evan I can put value in foreign key cell, which is not in primary key. I made it in MS Access. Is it possible in mysql?
if possible then plz help me. Remember-- I want to do that through PHP or PHPMYADMIN
arctushar
0
Junior Poster in Training
Recommended Answers
Jump to PostIf the tables already exists, make sure that:
-BOTH are using INNODB engine.
-In both tables, the fields are of the same type and size ( ex : INT(10))then try:
ALTER TABLE `childTableNameHere` ADD CONSTRAINT `parentTableNameHerechildTableNameHere` FOREIGN KEY (`parentTableNameHere_primaryFieldNameHere` ) REFERENCES `parentTableNameHere`( `primaryFieldNameHere` )
Jump to PostCan u plz explain what is different between normal engine and INNODB
In MySQL, foreign key constraints will only work on INNODB and BDB engines. The online manual explains the engines in details.
If your tables already have data, and the existing data violate the integrity contraints, then the …
All 6 Replies
hielo
65
Veteran Poster
arctushar
0
Junior Poster in Training
arctushar
0
Junior Poster in Training
hielo
65
Veteran Poster
arctushar
0
Junior Poster in Training
hielo
65
Veteran Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.