Long query ..HELP???

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
jamesloi
Forum Newbie
Posts: 15
Joined: Thu Jul 15, 2004 5:11 am
Location: London

Long query ..HELP???

Post by jamesloi »

hello..

I am getting the values $accountFrom , $accountTo and $amount
and i wish to use these in a query...

I am trying to update both accounts by the amount that is set by the user using a SINGLE query.. does anyone know if this can be done?

e.g. sorry for the bad SQL code

UPDATE G_ML_Account WHERE Account_Num='$accountFrom' SET MLM_Balance= MLM_Balance - '$amount'

UPDATE G_ML_Account WHERE Account_Num='$accountTo' SET MLM_Balance= MLM_Balance + '$amount'

Anyone know how i can combine these queries into 1 ?? 8)
User avatar
Lord Sauron
Forum Commoner
Posts: 85
Joined: Tue Apr 20, 2004 5:53 am
Location: Tilburg, NL

Post by Lord Sauron »

Code: Select all

<?php

IF (.......) {
    $MLM_Balance= $MLM_Balance - $amount;
}
ELSE {
    $MLM_Balance= $MLM_Balance + $amount;
}  

$this->MLM_Balance = $MLM_Balance;
$result = performQuery("UPDATE MLM_Balance_Table SET MLM_Balance = ".$this->MLM_Balance.";", "Database cannot perform query");

?>
Post Reply