sql中select 使用
You can get data out of tables using the SELECT
command.
您可以使用SELECT
命令从表中获取数据。
Get all rows and columns:
获取所有行和列:
SELECT * FROM people;
age | name
-----+--------
37 | Flavio
8 | Roger
Get only the name
column:
仅获取name
列:
SELECT name FROM people;
name
--------
Flavio
Roger
Count the items in the table:
计算表中的项目:
SELECT COUNT(*) from people;
count
-------
2
You can filter rows in a table adding the WHERE
clause:
您可以在添加WHERE
子句的表中过滤行:
SELECT age FROM people WHERE name='Flavio';
age
-----
37
The results of a query can be ordered by column value, ascending (the default) or descending, using ORDER BY:
查询结果可以使用ORDER BY按列值升序(默认)或降序排列:
SELECT * FROM people ORDER BY name;
SELECT * FROM people ORDER BY name DESC;
sql中select 使用