Devesh Agrawal
Devesh Agrawal

Reputation: 9212

what is the error in the given query

While a am executing the query

SELECT TIMESTAMPDIFF(SECOND, NOW(), 'select lastLoginTime from requests where id = 2 ')

Its returning NULL. Any idea why??

Upvotes: 1

Views: 101

Answers (1)

jcho360
jcho360

Reputation: 3759

mysql> SELECT TIMESTAMPDIFF(SECOND, NOW(), 'select last_update from t1 where actor_id = 2 ');
+--------------------------------------------------------------------------------+
| TIMESTAMPDIFF(SECOND, NOW(), 'select last_update from t1 where actor_id = 2 ') |
+--------------------------------------------------------------------------------+
|                                                                           NULL |
+--------------------------------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)

remove the ' and add ()

mysql> SELECT TIMESTAMPDIFF(SECOND, NOW(), (select last_update from t1 where actor_id = 2));
+-------------------------------------------------------------------------------+
| TIMESTAMPDIFF(SECOND, NOW(), (select last_update from t1 where actor_id = 2)) |
+-------------------------------------------------------------------------------+
|                                                                    -199167725 |
+-------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Upvotes: 2

Related Questions