MySQL Tutorial/Information Functions/USER
Версия от 13:44, 26 мая 2010; (обсуждение)
To extract only the username part
mysql>
mysql> SELECT SUBSTRING_INDEX(USER(),"@",1);
+-------------------------------+
| SUBSTRING_INDEX(USER(),"@",1) |
+-------------------------------+
| root |
+-------------------------------+
1 row in set (0.00 sec)
mysql>
USER() returns the current MySQL username and hostname
mysql>
mysql> SELECT USER();
+----------------+
| USER() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
mysql>