in reply to Re: Updating a mysql row
in thread Updating a mysql row

I absolutely disagree with your response to the OPs question, and thus downvoted you.

Especially someone unfamiliar with MySQL and the effects of uncertain statements, it's not necessarily better to try before you ask, moreso if they are working with a full database.

What should happen if it did update their database in such a way they did not intend and ruin their current database? Asking, in my opinion, should never be criticized. I'd sure prefer many professions to ask for help before trying it.

Replies are listed 'Best First'.
Re^3: Updating a mysql row - testing with a throwaway table
by imp (Priest) on Feb 22, 2007 at 23:27 UTC
    I wouldn't recommend running it on an active table, but testing it in a throwaway table is reasonably easy. From the mysql commandline client (using mysql 4.0 )
    mysql> create database pmtest; Query OK, 1 row affected (0.09 sec) mysql> use pmtest; Database changed mysql> create table t (id smallint, count smallint, time datetime); + Query OK, 0 rows affected (0.01 sec) mysql> insert into t values (1,1,now()); Query OK, 1 row affected (0.00 sec) mysql> insert into t values (2,1,now()); Query OK, 1 row affected (0.00 sec) mysql> insert into t values (3,1,now()); Query OK, 1 row affected (0.00 sec) mysql> update t set count=count+1, time=now() where id=2; Query OK, 1 row affected (0.02 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> update t set count=count+1, time=now() where id=2; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from t; +------+-------+---------------------+ | id | count | time | +------+-------+---------------------+ | 1 | 1 | 2007-02-22 19:26:39 | | 2 | 3 | 2007-02-22 19:27:06 | | 3 | 1 | 2007-02-22 19:26:45 | +------+-------+---------------------+ 3 rows in set (0.01 sec)
Re^3: Updating a mysql row
by Herkum (Parson) on Feb 23, 2007 at 02:08 UTC

    There should be no reason that a simple test cannot written to see if your code is working correctly. I don't understand why you think I was advocating that he run any code in production.

    Asking, in my opinion, should never be criticized

    Asking was not the problem, they just needed to check their work. If you have a person who is unwilling to try anything, how will they learn?