是否有查詢可以在兩個查詢中進行查詢?在一個查詢中進行選擇並更新
這是第
$q = "select c.id as campaignId,c.priceFactor,
o.cid,o.bloggerPrice,o.state as state,o.customerPrice,o.id as orderId,o.listPrice,o.basicPrice
from campaign c, orders o
where c.id={$campaignId}
and c.id = o.cid
and o.state in (8,9)";
這是第二
foreach($orders as $order)
{
$listPrice = $order->priceFactor * $order->basicPrice;
if($order->bloggerPrice < $listPrice || $order->customerPrice < $listPrice)
{
$order->bloggerPrice = $listPrice;
$order->customerPrice = $listPrice;
}
$qUpdate = "update orders set
listPrice = {$listPrice},bloggerPrice={$order->bloggerPrice},
customerPrice ={$order->customerPrice}
where id=$order->orderId and cid={$order->cid}";
// $this->db->q($qUpdate);
}
我的問題是:我能做到這一點上面沒有一個PHP代碼只是純粹的SQL?
你使用什麼數據庫服務器? MySQL,SQL Server,Oracle? – Andomar 2009-11-03 10:37:33
Mysql是數據庫服務器 – streetparade 2009-11-03 10:38:54