>데이터 베이스 >MySQL 튜토리얼 >mysql select语句中使用函数

mysql select语句中使用函数

WBOY
WBOY원래의
2016-06-01 09:56:481586검색

实例如下:

创建数据表:

<code class="language-sql">mysql> CREATE TABLE Employee(
    ->     id            int,
    ->     first_name    VARCHAR(15),
    ->     last_name     VARCHAR(15)
    -> );
Query OK, 0 rows affected (0.03 sec)</code>

 

向表中插入数据:

<code class="language-sql">mysql> insert into Employee(id,first_name, last_name)values (1,'Jason','Martin');
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> insert into Employee(id,first_name, last_name)values(2,'Alison','Mathews');
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> insert into Employee(id,first_name, last_name)values(3,'James','Smith');
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> insert into Employee(id,first_name, last_name)values(4,'Celia','Rice');
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> insert into Employee(id,first_name, last_name)values(5,'Robert','Black');
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> insert into Employee(id,first_name, last_name)values(6,'Linda', 'Green');
Query OK, 1 row affected (0.01 sec)

mysql>
mysql> insert into Employee(id,first_name, last_name)values(7,'David','Larry');
Query OK, 1 row affected (0.02 sec)

mysql>
mysql> insert into Employee(id,first_name, last_name)values(8,'James','Cat');
Query OK, 1 row affected (0.00 sec)</code>

select语句中使用函数

<code class="language-sql">mysql> SELECT concat(First_Name, " ",Last_Name) AS Name FROM Employee;
+----------------+
| Name           |
+----------------+
| Jason Martin   |
| Alison Mathews |
| James Smith    |
| Celia Rice     |
| Robert Black   |
| Linda Green    |
| David Larry    |
| James Cat      |
+----------------+
8 rows in set (0.00 sec)</code>

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.