mysql>
mysql> CREATE TABLE employees
-> (
-> id INT AUTO_INCREMENT PRIMARY KEY,
-> first_name VARCHAR(20) NOT NULL,
-> last_name VARCHAR(20) NOT NULL
-> );
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> # insert 7 records into the "employees" table
mysql> INSERT INTO employees (first_name, last_name) VALUES ("Arthur", "Smith");
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO employees (first_name, last_name) VALUES ("Peter", "Jones");
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO employees (first_name, last_name) VALUES ("Ann", "Smith");
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO employees (first_name, last_name) VALUES ("Sandra", "Williams");
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO employees (first_name, last_name) VALUES ("Andrew", "Smith");
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO employees (first_name, last_name) VALUES ("Paul", "Jones");
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO employees (first_name, last_name) VALUES ("Sally", "Williams");
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> SELECT * FROM employees;
+----+------------+-----------+
| id | first_name | last_name |
+----+------------+-----------+
| 1 | Arthur | Smith |
| 2 | Peter | Jones |
| 3 | Ann | Smith |
| 4 | Sandra | Williams |
| 5 | Andrew | Smith |
| 6 | Paul | Jones |
| 7 | Sally | Williams |
+----+------------+-----------+
7 rows in set (0.00 sec)
mysql>
mysql> # show both names sorted alphabetically
mysql> SELECT first_name, last_name FROM employees
-> ORDER BY last_name, first_name;
+------------+-----------+
| first_name | last_name |
+------------+-----------+
| Paul | Jones |
| Peter | Jones |
| Andrew | Smith |
| Ann | Smith |
| Arthur | Smith |
| Sally | Williams |
| Sandra | Williams |
+------------+-----------+
7 rows in set (0.00 sec)
mysql>
mysql> # delete this sample table
mysql> DROP TABLE employees;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>