查询数据

阅读量: 521 编辑

查询数据

where子句 :根据一定的条件查询

语法

- 全查询
SELECT *
FROM <table_name>
[WHERE Clause]

-- 列查询
SELECT <field-1>, <field-2>, ... ,<field-n>
FROM <table_name>
[WHERE Clause]

-- 别名
SELECT <field-1> [AS fieldName1], <field-2> [AS fieldName2]
FROM <table_name> AS t1
[WHERE Clause]

代码实战

SELECT * FROM student;

SELECT realname, username, education 
FROM student;

SELECT realname AS 'realName', username AS '登录名', education AS '学历'
FROM student AS t
WHERE t.id = 5;