mysql - Joining Tables to Update -
mysql - Joining Tables to Update -
can update row? first time using left join update.
update comments r left bring together items on i.items_id = r.item_id left bring together master_cat c on c.cat_id = i.items_id set r.good = r.good + 1 i.item = '{$item}' , c.category = '{$cat}' , r.review = '{$review}'; it doesn't throw error, says 0 rows affected though have confirmed variables ok right data. (even if hard code data).
edit: have tried inner bring together well, , not work either.
edit 2: trying do, have these 2 queires , work fine. trying simplify code one. can done:
// query returns rate_id utilize "$review_id" in sec query. $query = " select r.rate_id comments r left bring together items on i.items_id = r.item_id left bring together master_cat c on c.cat_id = i.cat_id r.review = '{$review}' , i.item = '{$item}' , c.category = '{$cat}';"; $query = " update comments set = + 1 rate_id = '{$review_id}';";
your problem in update statement have mismatching bring together (cat_id items_id):
left bring together master_cat c on c.cat_id = i.items_id while in select (that working), have bring together correctly:
left bring together master_cat c on c.cat_id = i.cat_id mysql sql sql-update left-join
Comments
Post a Comment