MariaDB 简单SELECT语句,排序及注释

标签:
selectorderlimitdescmariadb |
分类: 数据库(RDBS/NoSQL) |
(jlive)[crashcourse]>SELECT products.prod_id,prod_name,prod_price FROM crashcourse.products;
+---------+----------------+------------+
| prod_id | prod_name
+---------+----------------+------------+
| ANV01
| ANV02
| ANV03
| OL1
| FU1
| SLING
| TNT1
| TNT2
| FB
| FC
| SAFE
| DTNTR
| JP1000
| JP2000
+---------+----------------+------------+
14 rows in set (0.00 sec)
排序并取前查询结果的前几项
(jlive)[crashcourse]>SELECT prod_id,prod_name,prod_price FROM products ORDER BY prod_price DESC,prod_id LIMIT 5;
+---------+--------------+------------+
| prod_id | prod_name
+---------+--------------+------------+
| JP2000
| SAFE
| JP1000
| ANV03
| DTNTR
+---------+--------------+------------+
5 rows in set (0.00 sec)
指定显示查询结果中的连续几行
(jlive)[crashcourse]>(jlive)[crashcourse]>SELECT prod_id,prod_name,prod_price FROM products ORDER BY prod_price DESC,prod_id LIMIT 1,3;
+---------+--------------+------------+
| prod_id | prod_name
+---------+--------------+------------+
| SAFE
| JP1000
| ANV03
+---------+--------------+------------+
3 rows in set (0.00 sec)
等同于
(jlive)[crashcourse]>SELECT
prod_id,prod_name,prod_price FROM products ORDER BY
prod_price DESC,1
+---------+--------------+------------+
| prod_id | prod_name
+---------+--------------+------------+
| SAFE
| JP1000
| ANV03
+---------+--------------+------------+
3 rows in set (0.00 sec)
(jlive)[crashcourse]>SELECT vend_id FROM products;
+---------+
| vend_id |
+---------+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+---------+
14 rows in set (0.00 sec)
(jlive)[crashcourse]>SELECT DISTINCT vend_id FROM products;
+---------+
| vend_id |
+---------+
|
|
|
|
+---------+
4 rows in set (0.00 sec)
注释
注释单行
-- comments 或
# comments
注释多行
http://s1/mw690/002BYBFzgy70dBBVWlG50&690简单SELECT语句,排序及注释" TITLE="MariaDB