...

View Full Version : How to add integer to a column?



KazeFlame
10-26-2012, 03:47 PM
Hello guys! Please teach me how to add an integer to a column.

Here is my code but it doesn't work.

$sql = "UPDATE `flashgames`.`flashgames` SET `views` = '+1' WHERE `flashgames`.`gameid` = 1;";

Fou-Lu
10-26-2012, 03:50 PM
This is a SQL issue, not a PHP one.
You cannot increment in SQL, you must set the value to its increment. That would be a simple SET `views` = `views` + 1.

paulinetaylor85
11-05-2012, 07:11 AM
You will insert a new table via using SQL code add your column follow it. I have given the example. Insert into Stu_Table values(1,'name');

Fou-Lu
11-05-2012, 05:56 PM
You will insert a new table via using SQL code add your column follow it. I have given the example. Insert into Stu_Table values(1,'name');

Um, what? Are you referring to the use of an auto increment pk? That will have no practical purpose on this issue; the OP is incrementing a different field in the db, not the primary key (which cannot be incremented as shown in the op as that would eventually cause conflict on other pk).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum