Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jieex6
Starting Member
2 Posts |
Posted - 2008-03-11 : 23:45:46
|
| SET AUTOCOMMIT=0;START TRANSACTION; BEGIN TRAN SELECT `amount` from myaccounts where `ID` IN (Select `ID` from transaction_accounts where `transactionID`= 4) IF `amount` > 10;BEGIN SELECT `amount` from myaccounts where `ID` IN (Select `ID` from transaction_accounts where `transactionID`= 4) UPDATE myaccounts SET amount = amount - 500 END; COMMIT;Hello.. could please anyway point out what im doing wrong here? i think i've got the syntax wrong somwhere..Basically i query the 'amount' value and if that amount value is greater than 10, i want to update it to a new value. Any help would be greatly appreciated.Thanks |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2008-03-12 : 00:18:17
|
| I'd suggest posting in the MySQL forum over at www.dbforums.com, you might get help faster as sqlteam is mssql focused. |
 |
|
|
jieex6
Starting Member
2 Posts |
Posted - 2008-03-12 : 00:21:56
|
| ok thanks manstill if anyone has a clue let me know |
 |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2008-03-12 : 21:35:59
|
| In most SQL it would beUPDATE myaccountsset amount=amount-500WHEREID in (blah...)AND amount>10Don't know about MySQL. |
 |
|
|
|
|
|