-2
行,所以我有一個PHP陣列看起來MySQL的UPDATE多行,但是單個列不同的值從數組提取
array('somehash' => 'someotherhash', 'somehash2' => 'someotherhash2');
這裏somehash = producthash和someotherhash = tohash
$db->query('UPDATE sometable SET status = '.self::STATUS_NOT_AVAILABLE.', towhere = '.self::TO_WHERE.', '.
.'tohash = WHEN or IF or ??? and how ?, '.
.'WHERE status = '.self::STATUS_AVAILABLE.' AND '.
.'producthash IN (' . implode(',' , $prodarray) . ')') or $db->err(__FILE__,__LINE__);
所以在上面的查詢中,我想要tohash
的值通過producthash
從php數組中取得mysql字段
像tohash = IF(producthash IN '.$prodarray.', $prodarray['producthash'] , whatever)
ofcourse上述IF不會工作的原因我沒有在$prodarray['producthash']
任何人producthash值知道解決的辦法,因爲我有數組中的超過1000米的價值觀和不希望運行一千更新
,因爲該表的唯一鍵是基於3場,我不具有所有三個字段值,而這樣做更新INSERT INTO對重複鍵不在這個原因可能。