Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
03-12-2014, 01:46 PM #1
- Join Date
- Oct 2009
- Thanked 3 Times in 3 Posts
updating field when `field1`+`field2` = 'string'
How do I update a counter field if field1 + a space + field2 equals $string.
UPDATE `counters` SET `counter1` = `counter1` + 1 WHERE `field1`.' '.`field2`` = '$string' LIMIT 1
03-17-2014, 06:38 PM #2
- Join Date
- Jan 2011
- Thanked 594 Times in 593 Posts
I think I'd split the string into the field names and use
Please notice I removed the ticks from "counter1" and used double quotes. Tick are for column names.UPDATE `counters` SET `counter1` = "counter1" + 1 WHERE `field1` = "first part of string" AND `field2`` = "Next part of string" LIMIT 1
Evolution - The non-random survival of random variants.
"If you leave hydrogen alone, for long enough, it begins to think about itself."
03-18-2014, 02:16 PM #3
i think concat would work
Code:UPDATE `counters` SET `counter1` = `counter1` + 1 WHERE CONCAT ( field1, field2 ) = '$string' LIMIT 1
Last edited by Arcticwarrio; 03-18-2014 at 02:18 PM.
There are 10 types of people on CodingForums,
Those who understand Binary and those who dont.
Get Cloud Hosting now from only£59 / month