sql
1INSERT INTO TABLE_A 2SELECT * 3FROM TABLE_B 4where date > 0 5order by id DESC 6limit 10;
テーブルBからテーブルAへコピーするSQL文です。
上記のSQL文をcodeigniterで実行したいのですがエラーが出てしまって実行出来ません。
php
1 $this->db->select('*'); 2 $this->db->insert('TABLE_A',$date); 3 $this->db->from('TABLE_B'); 4 $this->db->where($where); 5 $this->db->order_by('id', 'DESC'); 6 $this->db->limit(10);
エラー内容
レコードを更新するには、"set" メソッドを使う必要があります。
どのように記述したらcodeigniterで実行できるでしょうか・
-------------------------以下 10/28 15:28追記
趣旨から違う為書きませんでしたが、本来やりたい事は以下になります。
TABLE_AからTABLE_Bへインサート
インサートした物はDELETEです。
$time_start = microtime(true); $where = [ 'date >' => 0, ]; $this->db->order_by('id', 'DESC'); $this->db->limit(100000); $records = $this->db->get('TABLE_A')->result_array(); foreach ($records as $key =>$record) { $this->db->insert('TABLE_B', $record); $this->db->delete('TABLE_A', ['id' => $record['id']]); }
しかしこれだとなかなか遅い。。。
回答3件
あなたの回答
tips
プレビュー