BuildMyWeb Posted December 4, 2014 Share Posted December 4, 2014 (edited) i have: if( $stmt = $db_connect->prepare('UPDATE '.C_T_DRAGONS.' AS d, '.C_T_USERS.' AS u SET d.'.$prop.' = d.'.$prop.'+'.$val.', u.ap=u.ap-1 WHERE d.id = ? AND (SELECT u2.ap FROM '.C_T_USERS.' as u2 WHERE u2.id = ?) > 100') ) which echoes out as: UPDATE dragons AS d, users AS u SET d.claws_dam = d.claws_dam+1, u.ap=u.ap-1 WHERE d.id = ? AND (SELECT u2.ap FROM users as u2 WHERE u2.id = ?) > 100 and am getting the following response: Error : (1093) Table 'd' is specified twice, both as a target for 'UPDATE' and as a separate source for data will this have to be done in 2 queries? did a little searching and im thinking maybe the subquery is being refused? Edited December 4, 2014 by BuildMyWeb Quote Link to comment https://forums.phpfreaks.com/topic/292901-do-an-update-to-2-tables-conditional-to-field-value-in-one-table/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.