How to set a foreign key and retrieve or delete data from multiple tables?

Enforcing referential integrity at the database level is the way to go. I believe when you said you wanted the delete "to delete his all records from my tables" you meant deleting the row and all its child records. You can do that by using foreign keys and ON DELETE CASCADE CREATE TABLE students ( student_id INT NOT NULL, name VARCHAR(30) NOT NULL, PRIMARY KEY (student_id) ) ENGINE=INNODB; CREATE TABLE fee_details ( id INT, date TIMESTAMP, student_id INT, FOREIGN KEY (student_id) REFERENCES students(student_id) ON DELETE CASCADE ) ENGINE=INNODB With this, when a student is deleted from the students table, all its associated records will be deleted from fee_details.

Enforcing referential integrity at the database level is the way to go. I believe when you said you wanted the delete "to delete his all records from my tables" you meant deleting the row and all its child records. You can do that by using foreign keys and ON DELETE CASCADE.

CREATE TABLE students ( student_id INT NOT NULL, name VARCHAR(30) NOT NULL, PRIMARY KEY (student_id) ) ENGINE=INNODB; CREATE TABLE fee_details ( id INT, date TIMESTAMP, student_id INT, FOREIGN KEY (student_id) REFERENCES students(student_id) ON DELETE CASCADE ) ENGINE=INNODB; With this, when a student is deleted from the students table, all its associated records will be deleted from fee_details.

Friends please help me to find the search form and php script to retrieve and display selected data from multiple tables joined by foreign key. – Mujeeb Sep 6 at 19:28 thanks all......... – Mujeeb Sep 6 at 19:31.

You can try mysql_query() and mysql_assoc_array().

Enforcing referential integrity at the database level is the way to go. I believe when you said you wanted the delete "to delete his all records from my tables" you meant deleting the row and all its child records. You can do that by using foreign keys and ON DELETE CASCADE.

With this, when a student is deleted from the students table, all its associated records will be deleted from fee_details.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions