检索单个列
select prod_name from products;
上述语句利用select 语句从products表中检索一个名为prod_name的列,
所需要的列名在select 关键字之后给出,from关键字指出从其中检索数据的表名
检索多个列
select prod_name,prod_id,prod_name from products;
上述语句指定了三个列名,列名之间用逗号分隔
检索所有列
select * from products;
(*) 通配符,表示返回表中所有的列
检索不同的行(去重)
select distinct ptod_id from products;
distinct 关键字用于只返回不同的值
限制结果
-
限制行数 limit
select prod_name from products limit 5;
最多输出5条记录
select prod_name from products limit 5,5;
从第5行开始,输出5行
使用完全限定的表名
select 表名.列名 from 数据库名.表名