MySQL:Basic commands Answers

From virtualMV2015wiki
Jump to: navigation, search
 Home  MySQL < Basic commands <

Executing SQL Statements

Exercise 1: SQL and the ;

mysql> SELECT NOW();
+---------------------+
| now()               |
+---------------------+
| 2009-07-17 21:05:43 |
+---------------------+
1 row in set (0.00 sec)
 
mysql> SELECT NOW(), USER(), VERSION();
+---------------------+----------------+------------------+
| now()               | USER()         | VERSION()        |
+---------------------+----------------+------------------+
| 2009-07-17 21:05:43 | root@localhost | 5.1.36-community |
+---------------------+----------------+------------------+
1 row in set (0.00 sec)

Exercise 2: SQL and \g or \G

mysql> SELECT NOW(), USER(), VERSION()\g
+---------------------+----------------+------------------+
| NOW()               | USER()         | VERSION()        |
+---------------------+----------------+------------------+
| 2009-07-17 21:05:43 | root@localhost | 5.1.36-community |
+---------------------+----------------+------------------+
1 row in set (0.00 sec)
 
mysql> SELECT NOW(), USER(), VERSION()\G
************************ 1,row ****************************
    NOW(): 2009-07-17 21:05:43
   USER(): root@localhost
VERSION(): 5.1.36-community
1 row in set (0.00 sec)

Exercise 3: SQL over multiple lines

mysql>SELECT NOW(),
    -> USER(),
    -> VERSION()
    ->; 
+---------------------+----------------+------------------+
| now()               | USER()         | VERSION()        |
+---------------------+----------------+------------------+
| 2009-07-17 21:05:43 | root@localhost | 5.1.36-community |
+---------------------+----------------+------------------+
1 row in set (0.00 sec)


Icon References.png References


MySQL:Basic commands Answers. (2017). In virtualMV's ( Michael Verhaart ) wiki. Retrieved December 17, 2017, from http://www.virtualmv.com/wiki/index.php?title=MySQL%3ABasic_commands_Answers    (zotero)