让我们首先创建一个表-
mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(100), -> Age int -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable(Name,Age) values('Robert',24); mysql> insert into DemoTable(Name,Age) values('Chris',22);
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
输出结果
+----+--------+------+ | Id | Name | Age | +----+--------+------+ | 1 | Robert | 24 | | 2 | Chris | 22 | +----+--------+------+ 2 rows in set (0.00 sec)
这是使用SELECT时添加新列的查询-
mysql> select Id,Name,Age,'US' AS DefaultCountryName from DemoTable;
输出结果
+----+--------+------+--------------------+ | Id | Name | Age | DefaultCountryName | +----+--------+------+--------------------+ | 1 | Robert | 24 | US | | 2 | Chris | 22 | US | +----+--------+------+--------------------+ 2 rows in set (0.00 sec)