- This topic is empty.
-
AuthorPosts
-
October 21, 2011 at 5:48 pm #34864binboyParticipant
Why don’t work this query for delete?(How can done best SQL for delete rows in following five table)?
$this->db->query("
DELETE tour_foreign
FROM tour_foreign
JOIN tour_foreign_residence
ON tour_foreign.id = tour_foreign_residence.relation
JOIN tour_foreign_units
ON tour_foreign_units.hotel_id = tour_foreign_residence.hotel_id
JOIN tour_foreign_image
ON tour_foreign.id = tour_foreign_image.relation
JOIN tour_foreign_prices_changing
ON tour_foreign_prices_changing.hotel_id = tour_foreign_residence.hotel_id
WHERE tour_foreign.id = $id));
table_1.id => this have id 65
table_2.rela => this have rela 65
table_2.h_id => this have h_id 11
table_3.h_id => this have h_id 11
table_4.rela => this have rela 65
table_5.h_id => this have h_id 11in tour_foreign.id one row have 65 and also is for tour_foreign_residence and tour_foreign_image that have relation 65 (tour_foreign.id = tour_foreign_residence.relation => 65 = 65, tour_foreign.id = tour_foreign_image.relation => 65 = 65,) now in tour_foreign_residence we have a column name hotel_id that have number 11 and it is set with hotel_id in tables[tour_foreign_units, tour_foreign_prices_changing].
How with there this relationship can get a id from tour_foreign and delete other rows in other tables.i mane is this: (with have one id from tour_foreign we can delete other rows relationship with it in tables their, in following is a example from this relationship)
tour_foreign.id = 65 => tour_foreign_image.relation = 65 => tour_foreign_residence.relation = 65 -> tour_foreign_residence.hotel_id = 11 => tour_foreign_units.hotel_id = 11 => tour_foreign_prices_changing.hotel_id = 11.
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.