02-26-2008, 05:07 PM
|
#1 (permalink)
|
|
The Addict
Join Date: Nov 2007
Posts: 282
Thanks: 61
|
Complicated MySQL if statement/update
Right I'm trying to do the following:
(pseudo)
Code:
update tablename set `cash` = ( IF cash - # > 0 SET `cash` = `cash` - # ELSE SET `cash` = 0) WHERE uid = 1
How do I do this?
Someone said to use this yet I think its not how I think its supposed to be setup:
Code:
UPDATE `mem` SET `uM` = (
SELECT IF ((SELECT (`uM` - %d) FROM `mem` WHERE `uid` = %d) > 0),
(SELECT (`uM` - %d) FROM `mem` WHERE `uid` = $d),
0
)
__________________
PHP/XHTML Freelancer:
Cleanscript.com v3 - Programming starting at just $5 act now!
|
|
|
|