Try
UPDATE tablename SET value2=value1, value1=0 WHERE value1 > 3
You might also want to look at the REPLACE INTO syntax in the manual too, for completeness.
Be aware though that this won't work if you need to do a join, as the join processor cannot know if you have changed a value which it's trying to join on. You may need to use temporary tables in that case.
Cheers - Neil.
At 00:44 09/02/2004 +0000, you wrote:
Message-ID: <20040208040352.73655.qmail@xxxxxxxxxxxxxxxxxxxxxxx> Date: Sun, 8 Feb 2004 15:03:52 +1100 (EST) From: JeRRy <jusa_98@xxxxxxxxx> To: php-db@xxxxxxxxxxxxx MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Subject: Re: php-db Digest 8 Feb 2004 01:40:01 -0000 Issue 2250
Hi,
I want to grab a value from one table field and place another value in another table fied.
So If I had table value1 and it was set to 3 I want to recognise the value 3 and put value 1 in table value2.
Example:
value1: 3 value2: (blank)
So now I need to check value1 and MAKE SURE 3 is the value, if a lower value I want to do nothing. If 3 > than I want to use the value
Example 2:
value1: 0 (grab 3 and reset to 0, if higher than 3 do the same) value2: 1 (If value1 is 3 > than value 1 needs to go in value2)
But how can I achieve this?
The queries are ran once a day, no more. So when the query is ran I could than execute the second query to change the value#'s.
Would I be right in saying that I'd use a 'IF statement' for this? Or is there another way to do this?
I am not sure exactly about executing a query with the IF statement, I do know how to execute a message or HTML information to output to the webpage.
I've done some reading online, but have not found what I am requiring ... Could be looking in the wrong place, as usual. All help appreciated.
Jerry
======================================================== CaptionKit http://www.captionkit.com : Production tools for accessible subtitled internet media, transcripts and searchable video. Supports Real Player, Quicktime and Windows Media Player.
VideoChat with friends online, get Freshly Toasted every day at http://www.fresh-toast.net : NetMeeting solutions for a connected world.
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php