whats the point of specifying a table if now()
is going to be the same for any table.??
views:
103answers:
4
+7
A:
More on this
Try without specifying table, like this
SELECT NOW()
There are also
CURDATE() and CURTIME()
http://www.w3schools.com/sql/func_now.asp
EDIT: The same way in MS SQL, you can write a query like
SELECT getdate()
hgulyan
2010-05-27 21:33:19
+3
A:
You don't have to; you can just SELECT Now()
However, people tend to use it in conjunction with querying for fields from actual tables, and that's why you see it FROM TABLE
so often.
This is in re: MySQL 5
LesterDove
2010-05-27 21:34:39
+3
A:
As far as I know FROM was needed in the SQL-92 standard (at least; that was the version I was able to find with some nice BNF grammar moments ago).
Maybe the logic behind was "functions" should use tables for producing output, so you have to specify something. In fact, I see quite low practical value in a query that only outputs the actual time.
Scorchio
2010-05-27 21:46:00
There is a practical use in selecting current time. What if you want to know db server's time? What if you use stored procedures?
hgulyan
2010-05-27 22:05:58
If I would like to know the time on the db server it's okay, but if I would like to get some administrative information on my db server, I would query time with several other things together, not the time alone. That's why I said I can't see the point in querying the time in itself.
Scorchio
2010-05-27 22:16:16
What if you use windows application and you don't have any application server. How do you get current time? Do you get it from user's computer or db server's time? Maybe you doesn't have cases when you need db time, but there are cases when you really need it.
hgulyan
2010-05-27 22:21:53