Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
dinud123
Starting Member
3 Posts |
Posted - 2013-04-15 : 00:55:19
|
hi,I created a table called login having following fields : name varchar(10) ,login_time timestamp and logout_time timestamp default 0.Inserted values+------+---------------------+---------------------+name login_time logout_time+------+---------------------+---------------------+abc 2013-04-15 10:09:22 0000-00-00 00:00:00+------+---------------------+---------------------+//update querymysql> update login set logout_time=NOW() where name="abc";Query OK, 1 row affected (0.06 sec)Rows matched: 1 Changed: 1 Warnings: 0mysql> select * from login;+------+---------------------+---------------------+name login_time logout_time+------+---------------------+---------------------+abc 2013-04-15 10:09:50 2013-04-15 10:09:50+------+---------------------+---------------------+y did login_time get updated (in bold) when I actually wanted logout_time to get updated ?hjs |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-15 : 01:10:45
|
Can you post full structure of Login Table...Is there any triggers on that table or any default constraints...?NOTE: this is SQL Server forum, not the MySql.. Better to get quick and feasible responses by posting in dbForums.com--Chandu |
 |
|
dinud123
Starting Member
3 Posts |
Posted - 2013-04-15 : 01:16:16
|
quote: Originally posted by bandi Can you post full structure of Login Table...Is there any triggers on that table or any default constraints...?NOTE: this is SQL Server forum, not the MySql.. Better to get quick and feasible responses by posting in dbForums.com--Chandu
+-------------+-------------+------+-----+---------------------+-----------------------------+| Field | Type | Null | Key | Default | Extra |+-------------+-------------+------+-----+---------------------+-----------------------------+| name | varchar(10) | YES | | NULL | || login_time | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP || logout_time | timestamp | NO | | 0000-00-00 00:00:00 | |+-------------+-------------+------+-----+---------------------+-----------------------------+3 rows in set (0.20 sec) no triggers usedhjs |
 |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-15 : 01:22:58
|
See this login_time | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |For every update of table, login_time sholud be updated by default.. that is the reson you are getting updated current timestamp for login_time value--Chandu |
 |
|
dinud123
Starting Member
3 Posts |
Posted - 2013-04-15 : 01:27:44
|
quote: Originally posted by bandi See this login_time | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |For every update of table, login_time sholud be updated by default.. that is the reson you are getting updated current timestamp for login_time value--Chandu
thanksss.. that worked hjs |
 |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-15 : 01:29:03
|
quote: Originally posted by dinud123thanksss.. that worked hjs
Welcome --Chandu |
 |
|
|
|
|