Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

select now() from table, why do we specify a table?

Tags:

sql

mysql

whats the point of specifying a table if now() is going to be the same for any table.??

like image 387
Alex Gordon Avatar asked Mar 23 '26 04:03

Alex Gordon


2 Answers

Try without specifying table, like this

SELECT NOW()

There are also

CURDATE() and CURTIME()

More on this

http://www.w3schools.com/sql/func_now.asp

EDIT: The same way in MS SQL, you can write a query like

SELECT getdate()
like image 125
hgulyan Avatar answered Mar 24 '26 19:03

hgulyan


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.

like image 42
Scorchio Avatar answered Mar 24 '26 18:03

Scorchio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!