MySQL Forums
Forum List  »  Quality Assurance

connect two tables in mysql
Posted by: Abubaker Theiban
Date: March 20, 2012 03:32AM

Hi all

I'm building my website in Dreamweaver.

I have create my database in localhost and it consist of 3 tables Guest , Room , Service.

Guest consist of:
ID , First Name , Second Name , Last Name , Mobile , E-mail , Age , Gender , Indentification ID , Arrival Date , Departure Date , Guest Number , Price.

Room Number , Guest Room , Family Room , Businessman Room.

Service ID , Meals Service , Communication Service , Mobility Service.

All I want is to connect the tables with each others so I put in the Guest table the primary key of Room (Room Number) , Service (Service ID) and I add them as INDEX in the options.

Then I start to test my website and when the explorer start it gives me the message :

Cannot add or update a child row: a foreign key constraint fails (`online hotel reservation system`.`room`, CONSTRAINT `room_ibfk_1` FOREIGN KEY (`Room Number`) REFERENCES `guest` (`Guest ID`))

I do not know what to do so please anyone help me.

Options: ReplyQuote

Written By
connect two tables in mysql
March 20, 2012 03:32AM
March 30, 2012 01:02AM
March 27, 2012 07:35AM
March 30, 2012 01:04AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.