mysql - Updating Multiple Tables with Join -
i have following query works fine:
$query = "update mpt join compounds on compounds.mpt = mpt.id set mpt.supervisor_comments = " . $this->db->escape($comments['mpt']) . " compounds.id = " . $id;
and updates mpt table linked a row in compounds table particular id.
i try extending query update 2 fields @ once, however, @ point i'm told:
unknown column 'mpt.id' in 'on clause' update mpt, bpt join compounds on compounds.mpt = mpt.id , compounds.bpt = bpt.id set mpt.supervisor_comments = 'abcd' compounds.id = 5
even though in previous example worked fine... suggestions or advice?
$query = "update mpt, bpt join compounds on compounds.mpt = mpt.id , compounds.bpt = bpt.id set mpt.supervisor_comments = " . $this->db->escape($comments['mpt']) . " compounds.id = " . $id;
precedence join
operator higher comma in tables list, when joining bpt
compounds
table mpt
hasn't been joined yet. obvious fix count place parenthesis so:
update (mpt, bpt) join compounds on ...
Comments
Post a Comment